Remove (duplicate) failed TestNG result via test listener

后端 未结 3 1284
我在风中等你
我在风中等你 2021-01-13 06:50

Similar to the solution posted here TestNG retrying failed tests doesn't output the correct test results, I\'m trying to remove a (duplicate) test result using a test li

3条回答
  •  清歌不尽
    2021-01-13 07:24

    You can also try below code

       @AfterTest
    public void afterTest(ITestContext context) {
           Set passedTests = context.getPassedTests().getAllResults();
           passedTests.forEach(i -> {
               if (context.getFailedTests().getAllMethods().contains(i.getMethod())) {
                   context.getFailedTests().getAllMethods().remove(i.getMethod());
               }
            });
    }
    

提交回复
热议问题