Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/linux/24.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Selenium 重新运行TestNG测试不适用于所有测试_Selenium_Selenium Webdriver_Webdriver_Testng - Fatal编程技术网

Selenium 重新运行TestNG测试不适用于所有测试

Selenium 重新运行TestNG测试不适用于所有测试,selenium,selenium-webdriver,webdriver,testng,Selenium,Selenium Webdriver,Webdriver,Testng,我正在使用IRetryAnalyzer接口再次运行失败的测试用例。如果我的testngxml文件中只有一个测试,它就可以正常工作,但是如果我的XML文件中有多个测试,那么它只适用于第一个测试 根本原因:第二次测试的retryCount设置为1,我不确定如何重置它 现有未决问题: RetryAnalyzer.java public class RetryAnalyzer implements IRetryAnalyzer { private int retryCount = 0;

我正在使用IRetryAnalyzer接口再次运行失败的测试用例。如果我的testngxml文件中只有一个测试,它就可以正常工作,但是如果我的XML文件中有多个测试,那么它只适用于第一个测试

根本原因:第二次测试的retryCount设置为1,我不确定如何重置它

现有未决问题

RetryAnalyzer.java

public class RetryAnalyzer implements IRetryAnalyzer {

    private int retryCount = 0;
    private int maxRetryCount = 1;

    public boolean retry(ITestResult result) {
        if (retryCount < maxRetryCount) {
            retryCount++;
            return true;
        }
        return false;
    }

}
public class AnnotationTransformer implements IAnnotationTransformer {

     public void transform(ITestAnnotation annotation, Class testClass, Constructor testConstructor, Method testMethod) {
         annotation.setRetryAnalyzer(RetryAnalyzer.class); //to enable for all the methods.
    }
}
TestNG.xml

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite name="BrowserStack" >

    <listeners>
        <listener class-name="uk.co.gaurang.libs.ResultListener" />
        <listener class-name="uk.co.gaurang.libs.AnnotationTransformer" />

    </listeners>

    <test name="IPhone6S">
        <classes>
            <class name="uk.co.gaurang.tests.Demo"/>
        </classes>
    </test>

    <test name="IPhone6SPlus">
        <classes>
            <class name="uk.co.gaurang.tests.Demo"/>
        </classes>
    </test>
</suite>


在第二次测试中,您是否真的有任何失败的测试用例?@optimist\u croper是的,所有的测试都是同一条语句
Assert.AssertTrue(false)
所以我知道它们每次都会失败。问题还没有解决,这可以解释为什么它仍然失败。您应该通过提供示例(以及,为什么不,尝试解决问题并提出解决方案)对问题进行投票。