-
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
How to rerun skipped test cases using TestNG? #3126
Comments
@Kaveeshhh - Can you please help me understand as to what exactly are you trying to achieve here? A test method can be skipped due to the following reasons:
Please help answer the following questions:
|
@krmahadevan You're right about the limitations of retrying skipped tests with dependencies. However, for independent test cases that skip due to failures in @BeforeSuite, @BeforeTest, @BeforeClass, or @BeforeMethod annotations, we might not need to pinpoint the exact cause. In this scenario, would it be possible using TestNG to achieve a mechanism that simply retries the entire test class? |
@Kaveeshhh - When a test skips due to a configuration failure, TestNG does not tell you as to which config method failure caused the test to be skipped. So we wouldn't be able to run the actual required pre-requisites for a skipped test to be retried.
No. The current implementation doesnt have any way of doing this from within TestNG. |
On the other hand if you would like to retry a failed configuration method (just to rule out flakiness in the setup for e.g.,) you can try doing something like below: import org.testng.IConfigurable;
import org.testng.IConfigureCallBack;
import org.testng.ITestResult;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
public class AnotherSample implements IConfigurable {
private boolean fail = true;
@Override
public void run(IConfigureCallBack callBack, ITestResult testResult) {
callBack.runConfigurationMethod(testResult);
if (!testResult.isSuccess()) {
fail = false;
callBack.runConfigurationMethod(testResult);
}
}
@BeforeClass
public void beforeClass() {
if (fail) {
throw new RuntimeException();
}
}
@Test
public void test() {
System.err.println("Hello world");
}
} In the sample, we are doing the following:
Note: This will handle only configuration retries |
TestNG Version
7.4.0
Expected behavior
I want to re-run testng skipped test cases.
Actual behavior
Getting 'Test ignored.' message.
Is the issue reproducible on runner?
Test case sample
Contribution guidelines
Incase you plan to raise a pull request to fix this issue, please make sure you refer our Contributing section for detailed set of steps.
The text was updated successfully, but these errors were encountered: