In the TestNG framework, if there are any configuration failures, which means any issues in @BeforeTest, method, then usually the test execution skips the @Test methods.
To overcome this use configfailurepolicy=“continue” in testsuite.xml .The default value for configfailurepolicy is skip.
Here is the Code Sample.
testsuite.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite name="Suite1" configfailurepolicy="continue" verbose="1">
<test name="Regression1">
<classes>
<class name="test.java.my.codeSamples.CheckConfigFailureTest"></class>
</classes>
</test>
</suite>
CheckConfigFailureTest.java
package test.java.my.codeSamples;
import org.testng.Assert;
import org.testng.annotations.*;
public class CheckConfigFailureTest
{
@BeforeTest
public void chechBeforeFailure(){
System.out.println("chechBeforeClassFailure");
Assert.assertTrue(false);
}
@Test
public void doActualTest(){
System.out.println("doActualTest");
}
@Test
public void doActualTest2(){
System.out.println("doActualTest2");
}
}
Execution Result
Without configfailurepolicy=“continue”
With configfailurepolicy=“continue”