Reputation: 153
When running tests in parallel using TestNg, the reports, emailable and testng-results.xml seems to be getting overridden and show results from the last thread only and not combined of all the threads.
Sample testng.xml file
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" >
<suite name="Smoke Suite" parallel="tests" thread-count="2">
<groups>
<run>
<include name="Smoke"/>
</run>
</groups>
<test name="1">
<classes>
<class name="one">
<parameter name="executionId" value="UIXTC-"/>
</class>
</classes>
</test>
<test name="2">
<classes>
<class name="two">
<parameter name="executionId" value="UIXTC-"/>
</class>
</classes>
</test>
</suite>
surefire details
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.0.0-M4</version>
<configuration>
<suiteXmlFiles>
<suiteXmlFile>src/com/blueoptima/${MODULE}/suiteXmls/${SUITE}Suite.xml</suiteXmlFile>
</suiteXmlFiles>
<threadCount>${THREADS}</threadCount>
<environmentVariables>
<PROPERTIES_FILE>${PROPERTIES_FILE}</PROPERTIES_FILE>
</environmentVariables>
</configuration>
</plugin>
The emailable and testng-results xml show results of the test methods from test name "2" only, even though the testng-results.xml is able to read all test names.
Sample testng-results.xml output file
<?xml version="1.0" encoding="UTF-8"?>
<testng-results ignored="21" total="22" passed="1" failed="0" skipped="0">
<reporter-output>
</reporter-output>
<suite started-at="2021-01-28T18:06:49 IST" name="Smoke Suite" finished-at="2021-01-28T18:10:40 IST"
duration-ms="230568">
<groups>
<group name="sanity">
<method signature="method 2" name="method 2" class="Class 2"/>
<method signature="method 3" name="method 3" class="Class 3"/>
</group> <!-- sanity -->
<group name="Smoke">
<method signature="method 1" name="method 1" class="Class 1"/>
<method signature="method 2" name="method 2" class="Class 2"/>
<method signature="method 3" name="method 3" class="Class 3"/>
</group> <!-- Smoke -->
</groups>
<test-method signature="method 1" started-at="2021-01-28T18:09:24 IST" name="method 1" data-
provider="dataProviderForTest" finished-at="2021-01-28T18:10:32 IST" duration-ms="67731"
status="PASS">
<params>
<param index="0">
<value>
<![CDATA[{testCaseId=UIXTC-}]]>
</value>
</param>
</params>
<reporter-output>
</reporter-output>
</test-method>
As it can be seen, it is able to identify all 3 methods in smoke suite, but shows results for only 1 method.
Upvotes: 1
Views: 666
Reputation: 11
As a workaround to this issue , you can add junit listener (which captures all threads) in your testng xml as below
<suite name = "Sample Tests">
<listeners>
<listener class-name="org.uncommons.reportng.JUnitXMLReporter"/>
</listeners>
and convert the junit xml reports to a summarized html using the simple command line utility prettyjunit.
Upvotes: 1