Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/maven/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Eclipse TestNG框架Eclipe-log().all()未正确收集Json响应_Eclipse_Maven_Testng_Hamcrest - Fatal编程技术网

Eclipse TestNG框架Eclipe-log().all()未正确收集Json响应

Eclipse TestNG框架Eclipe-log().all()未正确收集Json响应,eclipse,maven,testng,hamcrest,Eclipse,Maven,Testng,Hamcrest,当我尝试使用log().all()json时,下面的代码没有正确打印 方法PUT- 请求-{“姓名”:“Ronak”,“工资”:“123”,“年龄”:“26”} 预期答复: { "status": "success", "data": { "name": "Ronak", "salary": "12

当我尝试使用
log().all()
json时,下面的代码没有正确打印

方法PUT-

请求-{“姓名”:“Ronak”,“工资”:“123”,“年龄”:“26”}

  • 预期答复:

      {
          "status": "success",
          "data": {
              "name": "Ronak",
              "salary": "123",
              "age": "26"
          },
          "message": "Successfully! Record has been updated."
      }
    
  • Eclipse日志中的实际响应:

      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

    重新启动APITesting\u BDD\u项目
    重新启动APITesting\u BDD\u项目
    0.0.1-快照
    重新启动APITesting\u BDD\u项目
    http://www.example.com
    UTF-8
    1.7
    1.7
    org.hamcrest
    汉克雷斯特
    2.2
    测试
    org.hamcrest
    汉克雷斯特图书馆
    2.2
    测试
    朱尼特
    朱尼特
    4.13
    测试
    放心吧
    放心
    4.3.1
    测试
    放心吧
    json模式验证器
    4.3.1
    放心吧
    json路径
    4.3.1
    放心吧
    xml路径
    4.3.1
    org.testng
    testng
    7.3.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();

      }
  }
  <groupId>RestAssuredAPITesting_BDD_Project</groupId>
  <artifactId>RestAssuredAPITesting_BDD_Project</artifactId>
  <version>0.0.1-SNAPSHOT</version>

  <name>RestAssuredAPITesting_BDD_Project</name>
  <!-- FIXME change it to the project's website -->
  <url>http://www.example.com</url>

  <properties>
      <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
      <maven.compiler.source>1.7</maven.compiler.source>
      <maven.compiler.target>1.7</maven.compiler.target>
  </properties>

  <dependencies>


          <dependency>
              <groupId>org.hamcrest</groupId>
              <artifactId>hamcrest</artifactId>
              <version>2.2</version>
              <scope>test</scope>
          </dependency>

          <dependency>
              <groupId>org.hamcrest</groupId>
              <artifactId>hamcrest-library</artifactId>
              <version>2.2</version>
              <scope>test</scope>
          </dependency>

          <dependency>
              <groupId>junit</groupId>
              <artifactId>junit</artifactId>
              <version>4.13</version>
              <scope>test</scope>
          </dependency>

      <!-- https://mvnrepository.com/artifact/io.rest-assured/rest-assured -->
      <dependency>
          <groupId>io.rest-assured</groupId>
          <artifactId>rest-assured</artifactId>
          <version>4.3.1</version>
          <scope>test</scope>
      </dependency>


      <!-- https://mvnrepository.com/artifact/io.rest-assured/json-schema-validator -->
      <dependency>
          <groupId>io.rest-assured</groupId>
          <artifactId>json-schema-validator</artifactId>
          <version>4.3.1</version>
      </dependency>

      <!-- https://mvnrepository.com/artifact/io.rest-assured/json-path -->
      <dependency>
          <groupId>io.rest-assured</groupId>
          <artifactId>json-path</artifactId>
          <version>4.3.1</version>
      </dependency>

      <!-- https://mvnrepository.com/artifact/io.rest-assured/xml-path -->
      <dependency>
          <groupId>io.rest-assured</groupId>
          <artifactId>xml-path</artifactId>
          <version>4.3.1</version>
      </dependency>

      <!-- https://mvnrepository.com/artifact/org.testng/testng -->
      <dependency>
          <groupId>org.testng</groupId>
          <artifactId>testng</artifactId>
          <version>7.3.0</version>
          <scope>test</scope>
      </dependency>
  </dependencies>