我用的是 testng+ExtentReports 组合生成的报告 可是踢除并不管用 testng 用的 6.10 版本
实现的是 ITestListener 接口的 onFinish 方法,最后重跑的结果全是 skip 状态
![[求助] ExtentReports 报告中如何踢除失败重跑的用例数插图 [求助] ExtentReports 报告中如何踢除失败重跑的用例数插图](https://www.playezu.com/wp-content/uploads/2022/08/f9f33caa-2e0a-4b0d-be00-0034d44b5632.pnglarge.png)
代码如下:
1、失败重跑文章源自玩技e族-https://www.playezu.com/192769.html
public class TestRetryAnalyzer implements IRetryAnalyzer{
//当前数
private int retryCount = 1;
//最多重跑次数
private int maxRetryTimes = Config.retryTimes;
@Override
public boolean retry(ITestResult result) {
if(retryCount <= maxRetryTimes){
result.setAttribute("RETRY", retryCount);
Log.info("用例:"+ result.getName()+" 正在进行第"+retryCount+"次失败重跑");
Reporter.log("用例:"+ result.getName()+" 正在进行第"+retryCount+"次失败重跑");
retryCount++;
return true;
}
return false;
}
}
2、添加失败重跑和踢除:文章源自玩技e族-https://www.playezu.com/192769.html
//剔除失败重跑的用例数
@Override
public void onFinish(ITestContext context) {
Iterator<ITestResult> listOfFailedTests = context.getFailedTests().getAllResults().iterator();
while(listOfFailedTests.hasNext()){
ITestResult failedTest = listOfFailedTests.next();
ITestNGMethod method = failedTest.getMethod();
if(context.getFailedTests().getResults(method).size()>1){
listOfFailedTests.remove();
}
}
extent.flush();
}
//给所有用例添加失败重跑机制
@Override
public synchronized void onStart(ITestContext context) {
Log.info("正在为所有测试方法添加失败重跑机制");
for(ITestNGMethod method: context.getAllTestMethods()){
method.setRetryAnalyzer(new TestRetryAnalyzer());
}
}
可是报告还是打印重跑的用例,而且状态是跳过状态
![[求助] ExtentReports 报告中如何踢除失败重跑的用例数插图1 [求助] ExtentReports 报告中如何踢除失败重跑的用例数插图1](https://www.playezu.com/wp-content/uploads/2022/08/89d340c5-c1b2-477c-8fd0-c3518d2cd759.pnglarge.png)
踢除没有起作用文章源自玩技e族-https://www.playezu.com/192769.html赤峰软件功能测试文章源自玩技e族-https://www.playezu.com/192769.html文章源自玩技e族-https://www.playezu.com/192769.html
未知地区 1F
好的,明天我试试
仅楼主可见没关系 我在研究一下请问是是如何解决的呀