Note
- Issue started appearing only after updating TestNG version from 6.8.8 to TestNG 6.11
- Issue occurs even with the latest versions of TestNG 7.0.0-beta1 and maven surefire 3.0.0-M1
- Issue is intermittent and cannot be reproduced for all runs even with the exact same suite,tests and parameters
- The NPE occurs only after all the tests are completed and appears just before the @AfterSuite method is executed.
- The Tests consist of selenium scripts which are run on a grid.
Not really sure why the issue is not reproducible always and why apparently(based on the strack trace) the test is returning null in XmlSuite Class in TestNG. Issue occurs even without using any custom listeners
POM.xml config for surefire and testng:
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>7.0.0-beta1</version>
</dependency>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.0.0-M1</version>
<configuration>
<!--<excludes> <exclude>**/integration/*Test.java</exclude> </excludes>
<suiteXmlFiles> <suiteXmlFile>src/test/resources/suite.xml</suiteXmlFile>
</suiteXmlFiles> -->
<skip>true</skip>
<argLine>-Xms4096m</argLine>
<systemProperties>
<property>
<name>app.env</name>
<value>${app.env}</value>
</property>
</systemProperties>
<workingDirectory>./</workingDirectory>
<reportsDirectory>${user.home}/report/reports_${report.directory}/</reportsDirectory>
</configuration>
<executions>
<execution>
<id>integration-test</id>
<phase>integration-test</phase>
<goals>
<goal>test</goal>
</goals>
<configuration>
<properties>
<property>
<name>usedefaultlisteners</name>
<value>false</value>
</property>
<property>
<name>listener</name>
<value></value>
</property>
</properties>
<skip>false</skip>
<excludes>
<exclude>none</exclude>
</excludes>
<suiteXmlFiles>
<suiteXmlFile>src/test/resources/${test.suite}</suiteXmlFile>
</suiteXmlFiles>
<printSummary>false</printSummary>
</configuration>
</execution>
</executions>
</plugin>
Suite.XML
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite name="Failed suite" parallel="tests" thread-count="5" verbose="3">
<test name="Test1" preserve-order="true">
<parameter name="country" value="us" />
<parameter name="language" value="en" />
<parameter name="env" value="" />
<parameter name="browser" value="" />
<classes>
<class name="com.test.tests">
<methods>
<include name="test1" />
</methods>
</class>
</classes>
</test>
<test name="Test2" preserve-order="true">
<parameter name="country" value="us" />
<parameter name="language" value="en" />
<parameter name="env" value="" />
<parameter name="browser" value="" />
<classes>
<class name="com.test.tests">
<methods>
<include name="test2" />
</methods>
</class>
</classes>
</test>
<test name="Test3" preserve-order="true">
<parameter name="country" value="us" />
<parameter name="language" value="en" />
<parameter name="env" value="" />
<parameter name="browser" value="" />
<classes>
<class name="com.test.tests">
<methods>
<include name="test3" />
</methods>
</class>
</classes>
</test>
<test name="Test4" preserve-order="true">
<parameter name="country" value="us" />
<parameter name="language" value="en" />
<parameter name="env" value="" />
<parameter name="browser" value="" />
<classes>
<class name="com.test.tests">
<methods>
<include name="test4" />
</methods>
</class>
</classes>
</test>
<test name="Test5" preserve-order="true">
<parameter name="country" value="us" />
<parameter name="language" value="en" />
<parameter name="env" value="" />
<parameter name="browser" value="" />
<classes>
<class name="com.test.tests">
<methods>
<include name="test5" />
</methods>
</class>
</classes>
</test>
</suite>
FULL STACK TRACE
java.lang.NullPointerException
at org.testng.xml.XmlSuite.getAllParameters(XmlSuite.java:434)
at org.testng.SuiteRunner.privateRun(SuiteRunner.java:367)
at org.testng.SuiteRunner.run(SuiteRunner.java:302)
at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:53)
at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:96)
at org.testng.TestNG.runSuitesSequentially(TestNG.java:1145)
at org.testng.TestNG.runSuitesLocally(TestNG.java:1067)
at org.testng.TestNG.runSuites(TestNG.java:997)
at org.testng.TestNG.run(TestNG.java:965)
at org.apache.maven.surefire.testng.TestNGExecutor.run(TestNGExecutor.java:283)
at org.apache.maven.surefire.testng.TestNGXmlTestSuite.execute(TestNGXmlTestSuite.java:75)
at org.apache.maven.surefire.testng.TestNGProvider.invoke(TestNGProvider.java:120)
at org.apache.maven.surefire.booter.ForkedBooter.invokeProviderInSameClassLoader(ForkedBooter.java:384)
at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:345)
at org.apache.maven.surefire.booter.ForkedBooter.execute(ForkedBooter.java:126)
at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:418)