简体   繁体   English

TestNG - 重试分析器不适用于多个测试数据排列

[英]TestNG - Retry analyzer not working with multiple test data permutation

I have a scenario where I need to retry failed cases, for which I am using RetryAnalyzer.我有一个需要重试失败案例的场景,为此我使用了 RetryAnalyzer。 Each test case has multiple test data under data provider.每个测试用例在数据提供者下都有多个测试数据。 For eg例如

@Test(dataProvider="sampleTest")
    public void testData(final String data){
        Assert.fail(data);
    }

    @DataProvider
    public Object[][] sampleTest(){
        return new Object[][]{
                {"data1"},
                {"data2"},
                {"data3"}
        };
    } 

I need to retry each failed test data 2 times for which I used RetryAnalyzer and here is the code我需要重试每个失败的测试数据 2 次,我使用了 RetryAnalyzer,这是代码

public class RetryAnalyzer implements IRetryAnalyzer {

    int retryCounter = 0;
    int retryLimit = 2;

    static Logger log = Logger.getLogger(RetryAnalyzer.class.getName());

    //Re-try running only the failed tests until retryLimit is reached
    @Override
    public boolean retry(ITestResult iTestResult) {
            if (retryCounter < retryLimit) {
                retryCounter++;
                log.info("Retrying test: " + iTestResult.getName() + " for "+ retryCounter +" time.");
                return true;
            } else {
                log.info("Test failed: " + iTestResult.getName() + " after retrying for "+ retryCounter +" time.");
                //I am resetting this counter so that if test case is marked as failed for a particular test data, subsequent test data retry must start from 0 count
                retryCounter = 0;
            }
        return false;
    }
}

Problem: The first test data if failed runs 3 times (1 actual + 2 retries), and the subsequent cases runs 3 more times the previous run ie data1 will run 3 times, data2 6 times and data3 9 times.问题:如果失败的第一个测试数据运行 3 次(1 次实际 + 2 次重试),随后的情况下运行 3 次,即data1将运行 3 次, data2将运行 6 次, data3将运行 9 次。

TestNG version - 6

Am i missing anything here?我在这里错过了什么吗? Why is the retries doubling for subsequent test data?为什么后续测试数据的重试次数会翻倍? I couldn't find anything helpful outside, any help here will be highly appreciated!我在外面找不到任何有用的东西,这里的任何帮助将不胜感激!

Thank You.谢谢你。

The issue was with TestNG version.问题出在 TestNG 版本上。 After upgrading the version to 7, the issue was resolve, no extra work was needed.将版本升级到7后,问题得到解决,无需额外工作。

https://github.com/cbeust/testng/issues/1946 https://github.com/cbeust/testng/issues/1946

https://github.com/cbeust/testng/pull/1948/commits/7d5e89d72208bc9600efe0d423298d45146d15d8 https://github.com/cbeust/testng/pull/1948/commits/7d5e89d72208bc9600efe0d423298d45146d15d8

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM