How to get testng emailable report from Jenkins machine to be attached to Jenkins build mail notification using surefire plugin
When we execute our test cases on our local machines, we will get the testng emailable report which is awesome summary.
The same will not get generated on same path when we run our test cases on remote/slave node on Jenkins, we need to use surefire report plugin to fetch the same an get attached to Jenkins build mail notification.
Please use the following snippet on your maven projects pom.xml file:-
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.19.1</version>
<configuration>
<testFailureIgnore>true</testFailureIgnore>
<properties>
<property>
<name>usedefaultlisteners</name>
<key>false</key>
</property>
</properties>
<suiteXmlFiles>
<suiteXmlFile>${suitefile}</suiteXmlFile>
</suiteXmlFiles>
<properties>
<property>
<name>testnames</name>
<value>all</value>
</property>
</properties>
</configuration>
</plugin>
</plugins>
</build>
In above snippet we are passing a parameter "suitefile" which will be our testng.xml file on pom.xml which will be dynamically fetched from a maven test command.
For ex: on our jenkins job, we will call maven test command as:
mvn test -pl mavenprojectname -Dsuitefile=testng.xml
From above command, whatever value we will pas sto -Dsuitefile= , the testng.xml file will be assigned to surefire report plugin and it starts tracking teh execution of that testng suite.
The same will not get generated on same path when we run our test cases on remote/slave node on Jenkins, we need to use surefire report plugin to fetch the same an get attached to Jenkins build mail notification.
Please use the following snippet on your maven projects pom.xml file:-
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.19.1</version>
<configuration>
<testFailureIgnore>true</testFailureIgnore>
<properties>
<property>
<name>usedefaultlisteners</name>
<key>false</key>
</property>
</properties>
<suiteXmlFiles>
<suiteXmlFile>${suitefile}</suiteXmlFile>
</suiteXmlFiles>
<properties>
<property>
<name>testnames</name>
<value>all</value>
</property>
</properties>
</configuration>
</plugin>
</plugins>
</build>
In above snippet we are passing a parameter "suitefile" which will be our testng.xml file on pom.xml which will be dynamically fetched from a maven test command.
For ex: on our jenkins job, we will call maven test command as:
mvn test -pl mavenprojectname -Dsuitefile=testng.xml
From above command, whatever value we will pas sto -Dsuitefile= , the testng.xml file will be assigned to surefire report plugin and it starts tracking teh execution of that testng suite.
Comments
Post a Comment