1

对于我的休息服务(创建学生),我必须传递一个 XML 请求(请求类型是 application/xml),如下所示:

<student>
 <name>abc</name>
 </age>
 <addresses>
  <add1>
     <add_line1>pqr</add_line>
     <city>sdf</city>
  </add1>
  <add2>
    <add_line1>pqr</add_line>
    <city>sdf</city>
  </add2>
 <addresses>
</student>

我们如何将整个 xml 传递给测试用例?

@Test
public final void testCreateStudent() {
string xmlstring=//whole xml in double quote
          expect()
             .statusCode(200)
                     .body(hasXPath("/Response/status[text()='true']")
                 .with()
                     .body(xmlstring)
         .when()
                     .post("/service/student/create");
}

我是这个领域的新手。谁能建议我如何有效地做到这一点?Xpath 是否适合获取状态?,如果我的回复是这样的:

<response>
  <id>123</id>
  <status>true</status>
<response>
4

0 回答 0