gpt4 book ai didi

azure-devops - 如何将 TestNG 或 Extent 报告与 Azure devops 集成?

转载 作者:行者123 更新时间:2023-12-04 13:39:27 26 4
gpt4 key购买 nike

JUnit 报告可以与 Devops 集成,有没有办法将 TestNG 或 Extent 报告与 Azure devops 集成?

最佳答案

is there a way to integrate TestNG or Extent reports with Azure devops?



答案是肯定的。

如您所知,maven 任务与 Devops 集成得很好。我们可以通过 <suiteXmlFile>suites-test-testng.xml</suiteXmlFile> 在 maven 中添加 testng 套件在 pom.xml文件:

而且,我们需要添加 maven-surefire-plugin ,用于配置和执行测试。这里所说的插件用于配置 testng.xmlsuites-test-testng.xml用于TestNG测试并生成测试报告。

所以, 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 mave n 和 Publishing TESTNG test results into Azure DevOps一些细节。

希望这可以帮助。

关于azure-devops - 如何将 TestNG 或 Extent 报告与 Azure devops 集成?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59677823/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com