TestNG RetryAnalyzer类无法与RestAssured测试一起使用

问题描述

我尝试使用TestNG为Rest Assured API Test实施重试策略。

重试类:

public class RetryAnalyzer implements IRetryAnalyzer {

    private int counter = 0;
    private int retryLimit = 10;

    @Override
    public boolean retry(ITestResult iTestResult) {
        if(counter < retryLimit)
        {
            counter++;
            return true;
        }
        return false;
    }
}

我的测试:

    @Test(retryAnalyzer = RetryAnalyzer.class)
    public void newCustomer() {

        Response response =

        given().spec(custServiceApi).
        when().log().ifValidationFails().
                post("/api/v10/customers/submit").
        then().
                assertThat().statusCode(200).extract().response();

        String json = response.getBody().asString();

        JsonPath jsonPath = new JsonPath(json);

        String customerStatus = jsonPath.getString("status");

        assertEquals( "SUCCESSZ",customerStatus);

    }

我故意通过添加'Z'来迫使它失败,并且我希望它在10次之后失败。但是,第一次尝试失败。我要去哪里错了?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...