You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Encountered a problem when exception is thrown in the dataprovider, onTestSkipped method of listener is called but it is marked as failed in the report(ITestResult object FAILURE status)
packagetestngPackage;
importorg.testng.annotations.DataProvider;
importorg.testng.annotations.Test;
importstaticorg.testng.Assert.assertTrue;
/**- If the exception is encountered in the dataprovider * */publicclassSkippedAndFailedTest {
@DataProvider(name = "Skipped&FailedTest")
publicObject[][] createData3() {
Object[][] obj = newObject[][] {
{ "Welcome", newInteger(01) },
};
try {
if(obj != null)
thrownewException("Exception in the Dataprovider");
} catch (Exceptione) {
assertTrue(false, e.getMessage());
}
returnobj;
}
@Test(dataProvider = "Skipped&FailedTest")
publicvoidverifyData3(Stringn1, Integern2) {
System.out.println(n1 + " " + n2);
}
}
onStart
invoked onTestSkipped
onFinish
Suite
Total tests run: 1, Failures: 1, Skips: 0
IN generateReport
--- resultMap based on the test status ===> [TestResult name=verifyData3 status=FAILURE method=SkippedAndFailedTest.verifyData3(java.lang.String, java.lang.Integer)[pri:0, instance:testngPackage.SkippedAndFailedTest@721708f9] output={null}]
The text was updated successfully, but these errors were encountered:
The issue is reproducible for me as well. Skipped tests are being displayed as failed by SuiteRunnerWorker.java. Below is a sample output that confirms the behaviour:
TEST_API
Tests run: 2, Failures: 0, Skips: 2
TEST_API_Suite
Total tests run: 2, Failures: 2, Skips: 0
I did some analysis on the flow, here is what I have found so far:
In the Invoker.invokeTestMethods(..) method, the current test's result status is set to skipped(3) from failed(2) when there are errors in DP by registerSkippedTestResult() method but the test context(m_testContext) is not being updated anywhere. Since the final suite level stats are being pulled from test context, the skipped tests are being shown as failed ones.
We have found this issue when one of our user reported a bug against apache/maven-surefire-plugin.
Obviously this bug belongs to TestNG. apache/maven-surefire#70
We found that the TestNG 5.x marked the test with a failure if DataProvider thew an exception.
Currently TestNG 6.8.8 changed the behavior and listener calls onTestSkipped which results in situations where people report against apache/maven-surefire-plugin.
Are you willing to keep the behavior of TestNG 5.x in regard of this usecase please?
Encountered a problem when exception is thrown in the dataprovider, onTestSkipped method of listener is called but it is marked as failed in the report(ITestResult object FAILURE status)
onStart
invoked onTestSkipped
onFinish
Suite
Total tests run: 1, Failures: 1, Skips: 0
IN generateReport
The text was updated successfully, but these errors were encountered: