Java 如何在testNg中运行套件后重新运行失败的测试用例
下面是testNg.xml中的testcaseJava 如何在testNg中运行套件后重新运行失败的测试用例,java,selenium,testng,Java,Selenium,Testng,下面是testNg.xml中的testcase `<test name="Subset_TC01"> <parameter name="InputExcelPath" value="Subset_TC01.xls" /> <classes> <class name="com.idp.testcases.nbp.Mainflow"> <methods>
`<test name="Subset_TC01">
<parameter name="InputExcelPath" value="Subset_TC01.xls" />
<classes>
<class name="com.idp.testcases.nbp.Mainflow">
<methods>
<include name="testLogin" />
<include name="testLandingPage" />
<include name="testSearch" />
<include name="testInsuredInformationPage" />
</methods>
</class>
</classes>
</test>
<test name="Subset_TC02">
<parameter name="InputExcelPath" value="Subset_TC02.xls" />
<classes>
<class name="com.idp.testcases.nbp.Mainflow">
<methods>
<include name="testLogin" />
<include name="testLandingPage" />
<include name="testSearch" />
<include name="testInsuredInformationPage" />
</methods>
</class>
</classes>
</test>`
`
`
我试过的代码
`public class RetryAnalyzerImpl implements IRetryAnalyzer{
private int retryCount = 0;
private int maxRetryCount = 1;
@Override
public boolean retry(ITestResult arg0) {
if(retryCount < maxRetryCount) {
retryCount++;
return true;
}
return false;
}
}`
`公共类RetryAnalyzerImpl实现IRetryAnalyzer{
private int retryCount=0;
private int maxRetryCount=1;
@凌驾
公共布尔重试(ITestResult arg0){
如果(retryCount
但是这只会单独重新运行失败的测试方法,而不是整个测试用例
请帮助我找到一个解决方案,自动重新运行整个测试用例(例如,在本例中为Subset_TC01)我认为没有办法重新运行整个测试(xml测试)。作为一种解决方法,您可以设置测试用例的依赖关系,因此在重新运行时,它可能也会运行依赖的测试用例。不确定我们是否可以提取失败的测试用例,然后创建一个套件从java运行。
IRetryAnalyzer
仅用于测试方法重试,而TestNG不提供任何重试其他内容的方法。@juherr:Thanku