I have a flaky test which fails once per 10-20 attempts because of intermittently reproducible bug. I'd like to have this test to be marked as Failed after first failure. No further retries needed.
This is how the Test annotation looks like:
@Test(invocationCount = 20, threadPoolSize = 3)
The problem is that if it fails not in the last round - Allure report treat it as "Flaky" test and the report is green. What I'm trying to achieve is terminate test method retrying after the first failure. This test should be red in Allure report.
The annotations are set before runtime, so once you are running the test, you cannot change the invocationCount.
What you can do, is to use a listener to stop the execution when it reaches
onTestFailure
.So let's say you have the test class:
Then the listener will abort th execution if there's a single failure and stop from running the rest of the tests: