黄瓜步重复NullPointerException

时间:2018-04-20 15:56:42

标签: java cucumber cucumber-jvm rest-assured

我正在尝试运行功能a和功能b,它具有相同的步骤     下面

feature a:

Scenario Outline: Verify correct entity values
  When  Performing the get request to localhost:"<port>"/"<endpoint>"
   Then The response status should be 200 and json body containing "Apps is running"

feature b: 

Scenario Outline: Verify incorrect entity values
    When Performing the post request with correct file to localhost:"<port>"/"<endpoint>""<superregion>""<entity>""<filename>""<contenttype>"
    Then The response status should be 400 and response message is "<entity> is not a valid entity type."
    Examples:
      | port | endpoint     | superregion | entity | filename | contenttype |
      | 8081 | api/v1/admin | ANBS        | V      | anbs.tsv | anbsFile    |

当我尝试使用相同的步骤时,我收到一条错误消息:

# CheckTest.checkJsonBodyContains(int,String)
  java.lang.NullPointerException
    at com.apitesting.steps.checkJsonBodyContains(CheckTest.java:27)
    at ✽.The response status should be 201 and json body containing "success"(src/test/resources/features/GSOUpload.feature:6)

这是checkJsonBodyContains的主体:

    @Then("^The response status should be (\\d{3}) and json body containing \"([^\"]*)\"$")
    public void checkJsonBodyContains(int statusCode, String message){
        assertEquals(statusCode, response.getStatusCode());
        assertThat(response.getBody().asString(), containsString(message));
    }**

请帮我解决如何解决空指针异常上述步骤我正在重复使用很多测试。

0 个答案:

没有答案