简体   繁体   English

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

[英]How to integrate TestNG or Extent reports with Azure devops?

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

is there a way to integrate TestNG or Extent reports with Azure devops?有没有办法将 TestNG 或 Extent 报告与 Azure devops 集成?

The answer is yes.答案是肯定的。

As you know the maven task integrate with Devops very well.如您所知,maven 任务与 Devops 集成得很好。 We could add testng suites in maven by <suiteXmlFile>suites-test-testng.xml</suiteXmlFile> in pom.xml file:我们可以通过pom.xml文件中的<suiteXmlFile>suites-test-testng.xml</suiteXmlFile>在 maven 中添加 testng 套件:

And, we need add maven-surefire-plugin , which is used to configure and execute the tests.并且,我们需要添加maven-surefire-plugin ,用于配置和执行测试。 Here the said plugin is used to configure the testng.xml and suites-test-testng.xml for the TestNG test and generate test reports.这里所说的插件用于为TestNG测试配置testng.xmlsuites-test-testng.xml并生成测试报告。

So, the pom.xml looks like:所以, 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>

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.发布 TESTNG 测试结果,因为 Azure DevOps 不支持 TESTNG 测试结果格式,但 TESTNG 还在单独的 junitreports 文件夹中生成 JUnit 测试结果。 So, we can publish TESTNG test results in JUnit format instead.因此,我们可以改为以 JUnit 格式发布 TESTNG 测试结果。

To do that, just change Test results files field under JUnit Test Results section to **/junitreports/TEST-*.xml .为此,只需将 JUnit 测试结果部分下的测试结果文件字段更改为**/junitreports/TEST-*.xml

Check the document How to run testng.xml from mave n and Publishing TESTNG test results into Azure DevOps for some details.查看文档How to run testng.xml from mave n and Publishing TESTNG test results into Azure DevOps了解一些详细信息。

Hope this helps.希望这可以帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM