【发布时间】:2020-01-13 13:37:20
【问题描述】:
JUnit 报告可以选择与 Devops 集成,有没有办法将 TestNG 或 Extent 报告与 Azure devops 集成?
【问题讨论】:
标签: azure-devops testng extentreports
JUnit 报告可以选择与 Devops 集成,有没有办法将 TestNG 或 Extent 报告与 Azure devops 集成?
【问题讨论】:
标签: azure-devops testng extentreports
有没有办法将 TestNG 或范围报告与 Azure devops 集成?
答案是肯定的。
如您所知,maven 任务与 Devops 集成得非常好。我们可以通过 <suiteXmlFile>suites-test-testng.xml</suiteXmlFile> 在 pom.xml 文件中添加 maven 中的 testng 套件:
而且,我们需要添加maven-surefire-plugin,用于配置和执行测试。这里所说的插件用于为TestNG测试配置testng.xml和suites-test-testng.xml并生成测试报告。
所以,pom.xml 看起来像:
<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>
要发布 TESTNG 测试结果,因为 Azure DevOps 不支持 TESTNG 测试结果格式,但 TESTNG 还会在单独的 junitreports 文件夹中生成 JUnit 测试结果。因此,我们可以改为以 JUnit 格式发布 TESTNG 测试结果。
为此,只需将 JUnit 测试结果部分下的测试结果文件字段更改为 **/junitreports/TEST-*.xml。
查看文档How to run testng.xml from maven 和Publishing TESTNG test results into Azure DevOps 了解一些详细信息。
希望这会有所帮助。
【讨论】: