-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
RetryAnalyzer triggered before @AfterMethod #3154
Comments
Hi, @vlad8x8. Please help share a Minimal, Reproducible Example that can be used to recreate the issue. In addition to sharing a sample, please also add the following details:
It would be better if you could share a sample project that can be directly used to reproduce the problem. |
https://github.com/testng-team/testng/blob/master/testng-core/src/main/java/org/testng/internal/invokers/TestInvoker.java#L548C1-L554C38 |
https://github.com/vlad8x8/testng-retry-bug Output:
|
Not sure what the question is @vlad8x8 On a side note, you seem to have spent time on debugging this issue. Would you like to help raise a pull request to get this fixed? We can help you with getting it merged. |
Hi @krmahadevan, sorry for that emotional exclamation. I just don't understand why we setWasRetried before doing any retry. |
Your test was run twice. The first iteration failed, and so was retried and hence it was marked as Your If you add a listener as below you should see the output explaining to you what is going on. import org.testng.ITestContext;
import org.testng.ITestListener;
import org.testng.ITestResult;
import java.util.Collection;
public class Printer implements ITestListener {
@Override
public void onFinish(ITestContext context) {
show("Skipped", context.getSkippedTests().getAllResults());
show("Failed", context.getFailedTests().getAllResults());
show("Passed", context.getPassedTests().getAllResults());
}
private void show(String prefix, Collection<ITestResult> results) {
System.err.println(prefix + ", Size = " + results.size());
for (ITestResult result : results) {
System.err.println(result + ", Retried ? " + result.wasRetried());
}
}
} The output would look like below: ---------------------------------------------
Try number: 0
Is this real retry: false
Test ignored.
After method:
Is result thinks that it was retried? true
---------------------------------------------
Try number: 1
Is this real retry: true
After method:
Is result thinks that it was retried? false
Skipped, Size = 1
[TestResult name=test status=SKIP method=MyTest.test()[pri:0, instance:com.github.issue3154.MyTest@7c469c48] output={null}], Retried ? true
Failed, Size = 0
Passed, Size = 1
[TestResult name=test status=SUCCESS method=MyTest.test()[pri:0, instance:com.github.issue3154.MyTest@7c469c48] output={null}], Retried ? false
===============================================
Default Suite
Total tests run: 2, Passes: 1, Failures: 0, Skips: 0, Retries: 1
===============================================
|
TestNG Version
7.10.2
Expected behavior
RetryAnalyzer triggered after @AfterMethod
ITestResult.wasRetried() returns false in @AfterMethod before retry
Actual behavior
RetryAnalyzer triggered before @AfterMethod
ITestResult.wasRetried() returns true in @AfterMethod before retry
Is the issue reproducible on runner?
Maven
The text was updated successfully, but these errors were encountered: