在断言状态码时,resassured 中的类型变得不明确

问题描述 投票:0回答:1

我放心地使用了黄瓜BDD。我的功能文件包含 * 然后状态代码为 200 * 在步骤定义中,在将状态代码断言为参数时,我收到了上述错误。

我尝试将功能文件参数转换为字符串文字,然后断言预期的状态代码,但收到不同的错误。

这是我的代码:

@Then("statuscode is {int}") 
Public void status_code_is(Integer int) { 
    assertEqual(response.getStatusCode(),int) ; 
}
cucumber rest-assured web-api-testing
1个回答
0
投票

这里有两个问题:

  1. 在Java中没有

    Public
    ,是
    public

  2. int
    是Java中的保留关键字,请为参数选择其他名称。

public void status_code_is(Integer statusCode){
   assertEqual(response.getStatusCode(), statusCode) ; 
}
© www.soinside.com 2019 - 2024. All rights reserved.