Reputation: 718
I have an xml file with test classes.This is my testng suite xml. Each test class, has the following structure:
@BeforeClass
public void beforeClass(){
}
@Test(dataProvider="Mail Information")
public void mailSend(String to,String subject,String body) throws Exception{
}
@AfterClass{
}
When I mistakenly put a null object in AfterClass
, the test correctly failed, with java.lang.NullPointerException
, but instead of continuing to the other tests of the suite, all the other tests became Skipped.
I assume that they become skipped, because their @beforeClass
became skipped. So I think that the real problem is that a failure in AfterClass
, somehow affected the BeforeClasses of the following tests in suite.
How can we handle such problem?
Upvotes: 0
Views: 2500
Reputation: 89
I try this way "alwaysRun = true" to always run the function on @AfterClass annotation. Although any @Test has NullPointerException
@AfterClass(groups = { "smoke" }, alwaysRun = true)
private void stoptream() {
Stream.tryForceStop3times(id, data);
}
Upvotes: 0
Reputation: 718
After a long long time, I found the solution to my problem.. It all goes away, by adding in the suite tag, the entryconfigfailurepolicy, and set it to continue, in your suite xml files like this:
<suite name="Test-Suite" configfailurepolicy="continue">
By default the value of the parameter was skip, which was causing tests to skip, if a failed configuration occured.
Upvotes: 4
Reputation: 1525
I haven't tried this but as per TestNG documentation it should solve your issue. Set the alwaysRun attribute to true for each of the test method.
Upvotes: 2