12
Sep

configfailurepolicy in TestNG

TestNG if a configuration failure happens the current behavior is any @Test method execution is skipped.

If you need to execute Tests despite configuration failures, configure configfailurepolicy="continue" at Suite Level.


eg.

if following tests are executed as "TestNGTest" @Test methods are skipped

	@BeforeTest
	public void bt() {
		assertTrue(false);
	}

	@Test
	public void tf() {
		System.out.println("My Function");
	}


===============================================
    Default test
    Tests run: 1, Failures: 0, Skips: 1
    Configuration Failures: 1, Skips: 0
===============================================


In order to run @Test irrespective of configurationFailures, following setting needs to be configured in testng.xml and all tests needs to be executed as TestNGSuite



<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite name="Suite" parallel="tests" thread-count="10" verbose="10" configfailurepolicy="continue">
 <listeners>
      <listener class-name="org.uncommons.reportng.HTMLReporter"/>
      <listener class-name="org.uncommons.reportng.JUnitXMLReporter"/>
      <listener class-name="utilities.TestListener" />
  </listeners>
    
  <test name="Test Chrome implicitNotVisible">
  <parameter name="targetEnvironment" value="Chrome" />
   <parameter name="network" value="" />
   <parameter name="networkLatency" value="" />
    <classes>
      <class name="AmazonTesting.SleepTestSystem">
       <methods>
     <include name="implicitNotVisible" />
        </methods>
        </class>
    </classes>  
  </test>
  </suite>