如何解决TestNG Framework Eclipe-logall未正确收集Json响应
对于以下代码,当我尝试使用public function loop1($ob):array {
return array(1,2,3);
}
时,json无法正确打印。
方法PUT-http://dummy.restapiexample.com/public/api/v1/update/6112
请求-{“名称”:“罗纳克”,“工资”:“ 123”,“年龄”:“ 26”}
-
预期响应:
log().all()
-
Eclipse日志中的实际响应:
{ "status": "success","data": { "name": "Ronak","salary": "123","age": "26" },"message": "Successfully! Record has been updated." }
-
我的代码:
JRE-JAVA 1.8 [jdk-AdoptOpenJDK 8.0]
Response: 200 Content-Length: 81 { "status": "success",**"data": [ ],** <--- **this value is missing here** "message": "Successfully! Record has been updated." } PASSED: testPUT
-
Pom.XML文件值:
4.0.0
package restassuredTests; import java.util.HashMap; import org.testng.annotations.BeforeClass; import io.restassured.RestAssured; import org.testng.annotations.Test; import static io.restassured.RestAssured.*; import static org.hamcrest.Matchers.*; public class Demo3_PUT_Request { public static HashMap map1 = new HashMap(); int id = 6112; @BeforeClass public void putData() { map1.put("name","Ronak"); map1.put("salary","123"); map1.put("age","26"); RestAssured.baseURI="http://dummy.restapiexample.com/public/api/v1"; RestAssured.basePath="/update/"+id; } @Test public void testPUT() { given() .contentType("application/json") .body(map1); when() .put() .then() .statusCode(200) .and() .body(containsString("success")) .and() .body(containsString("Successfully! Record has been updated.")) .log().all(); } }
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。