There is option for JUnit reports to integrate with Devops, is there a way to integrate TestNG or Extent reports with Azure devops?
1 Answers
is there a way to integrate TestNG or Extent reports with Azure devops?
The answer is yes.
As you know the maven task integrate with Devops very well. We could add testng suites in maven by <suiteXmlFile>suites-test-testng.xml</suiteXmlFile>
in pom.xml
file:
And, we need add maven-surefire-plugin, which is used to configure and execute the tests. Here the said plugin is used to configure the testng.xml
and suites-test-testng.xml
for the TestNG test and generate test reports.
So, the pom.xml
looks like:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.test.maven</groupId>
<artifactId>sample-maven-build</artifactId>
<version>1</version>
<name>sample-maven-build</name>
<build>
<!-- Source directory configuration -->
<sourceDirectory>src</sourceDirectory>
<plugins>
<!-- Following plugin executes the testng tests -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.14.1</version>
<configuration>
<!-- Suite testng xml file to consider for test execution -->
<suiteXmlFiles>
<suiteXmlFile>testng.xml</suiteXmlFile>
<suiteXmlFile>suites-test-testng.xml</suiteXmlFile>
</suiteXmlFiles>
</configuration>
</plugin>
<!-- Compiler plugin configures the java version to be usedfor compiling
the code -->
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<!-- Dependency libraries to include for compilation -->
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>6.3.1</version>
</dependency>
</dependencies>
</project>
To publish the the TESTNG test results, since Azure DevOps does not support TESTNG test results format, but TESTNG also produces JUnit test results in a separate junitreports folder. So, we can publish TESTNG test results in JUnit format instead.
To do that, just change Test results files field under JUnit Test Results section to **/junitreports/TEST-*.xml
.
Check the document How to run testng.xml from maven and Publishing TESTNG test results into Azure DevOps for some details.
Hope this helps.

- 71,098
- 10
- 114
- 135