小编Rah*_*l R的帖子

空手道测试框架中的重试机制

空手道测试框架中的重试机制 如何在空手道测试框架(如 Junit 和 TestNG)中对失败进行重试。类似公共类重试实现 IRetryAnalyzer {

private int count = 0;
private static int maxTry = 3;

@Override
public boolean retry(ITestResult iTestResult) {
    if (!iTestResult.isSuccess()) {                      //Check if test not succeed
        if (count < maxTry) {                            //Check if maxtry count is reached
            count++;                                     //Increase the maxTry count by 1
            iTestResult.setStatus(ITestResult.FAILURE);  //Mark test as failed
            return true;                                 //Tells TestNG to re-run the test
        } else {
            iTestResult.setStatus(ITestResult.FAILURE);  //If maxCount reached,test marked as failed
        }
    } else {
        iTestResult.setStatus(ITestResult.SUCCESS);      //If test …
Run Code Online (Sandbox Code Playgroud)

karate

5
推荐指数
1
解决办法
1494
查看次数

标签 统计

karate ×1