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
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());
}
});
}