After executing test cases through Jenkins job is there a way to run testng generated testng-failed.XML in post build section and publish rerun reports also? I have to do it in the same job. I shouldn't trigger another job for this. Thanks in advance!!!!
Asked
Active
Viewed 3,134 times
1 Answers
0
Do as follows, it will execute your testng-failed.xml file after testng.xml. The file should exist by the time its turn to execute comes. It will be executed only once.
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.17</version><!--$NO-MVN-MAN-VER$ -->
<configuration>
<!-- Sets the VM argument line used for unit tests are run. -->
<suiteXmlFiles>
<suiteXmlFile>src/test/resources/testng/testng.xml</suiteXmlFile>
<suiteXmlFile>target/surefire-reports/testng-failed.xml</suiteXmlFile>
</suiteXmlFiles>
</configuration>
</plugin>
*******UPDATE Implement a TestNg listener IReporter and configure it in your original testNg.xml file
It's method
GenerateReport()
Is invoked once all suites have run. In this method you must implement back up functionality of the generated testng-failed.xml . Once this is done, testNg will proceed to rerun the testNg-failed.xml file as per my previous mentioned Maven configuration.

DolphinJava
- 2,682
- 1
- 23
- 37
-
Thanks!!! But I should get first run reports and testng-failed.XML reports also . If we run failed.XML immediately the old reports will be overwritten. I was copying reports to a specified location using apache in post build section. I have to get both reports. – RaviTeja Oct 25 '14 at 09:58
-
RaviTeja posted the final correct answer. Read it once more and you will have the solution. – DolphinJava Oct 25 '14 at 11:20