zoukankan      html  css  js  c++  java
  • testng系列-ReportNG

      生成reportng报告操作步骤:

    一、maven的pom.xml文件需要添加内容:

    <properties>
            
            <!-- maven 参数配置,这里引用不同的testng.xml -->
            <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
            <xmlFileName>testng.xml</xmlFileName>
        </properties>
    <!-- https://mvnrepository.com/artifact/org.testng/testng -->
            <dependency>
                <groupId>org.testng</groupId>
                <artifactId>testng</artifactId>
                <version>6.9.10</version>
                <!-- <scope>compile</scope> -->
                  <scope>test</scope>  
            </dependency>
            <!-- 依赖reportNg 关联testNg-->
            <dependency>
                <groupId>org.uncommons</groupId>
                <artifactId>reportng</artifactId>
                <version>1.1.4</version>
                <scope>test</scope>
                <exclusions>
                    <exclusion>
                        <groupId>org.testng</groupId>
                        <artifactId>testng</artifactId>
                    </exclusion>
                </exclusions>
            </dependency>
             <!-- 依赖Guice -->
            <dependency>
                <groupId>com.google.inject</groupId>
                <artifactId>guice</artifactId>
                <version>3.0</version>
                <scope>test</scope>
            </dependency>
    <!--  build -->
            <build>
               <plugins>
                  <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-surefire-plugin</artifactId>
                    <version>2.18.1</version>
                    <configuration>
                        <systemPropertyVariables>
                            <org.uncommons.reportng.escape-output>false</org.uncommons.reportng.escape-output>
                        </systemPropertyVariables>
                        <properties>
                            <property>
                                <name>usedefaultlisteners</name>
                                <value>false</value>
                            </property>
                        </properties>
                        <suiteXmlFiles>
                            <suiteXmlFile>res/${xmlFileName}</suiteXmlFile>
                            <!--表示使用xmlFileName作为testNG的配置文件 -->
                        </suiteXmlFiles>
                        <testFailureIgnore>true</testFailureIgnore>
                        <!--当case错误的时候继续运行,否则当case错误的时候报build错误 -->
                    </configuration>
                </plugin>
                <!-- 添加插件,添加ReportNg的监听器,修改最后的TestNg的报告 -->
           <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>2.5</version>
                <configuration>
                    <properties>
                        <property>
                            <name>usedefaultlisteners</name>
                            <value>false</value>
                        </property>
                        <property>
                            <name>listener</name>                      
                            <value>org.uncommons.reportng.HTMLReporter,  org.uncommons.reportng.JUnitXMLReporter</value>
                        </property>
                    </properties>
                    <workingDirectory>target/</workingDirectory>
                    <forkMode>always</forkMode>
                </configuration>
               </plugin>
               </plugins>
            </build>

    备注:以上内容添加完成后运行Maven  install确保依赖包加载到工程的Maven Dependencies里边;

    二、testng的testng.xml文件需要添加内容:

        <listeners>
            <listener class-name="org.uncommons.reportng.HTMLReporter" />
            <listener class-name="org.uncommons.reportng.JUnitXMLReporter" />
        </listeners>

    三、选中pom.xml执行Maven test后测试报告艘在位置及最终效果如下:

    1)位置

    2)效果

  • 相关阅读:
    微信第三方平台开发之代小程序实现业务
    解决Chrome网页编码显示乱码的问题
    .Net Core 使用 System.Drawing.Common 在CentOS下报错
    CentOS安装nmap端口查看工具
    解决Nginx反向代理不会自动对特殊字符进行编码的问题 如gitblit中的~波浪线
    Centos7最小安装化后安装图形界面
    手把手教您在 Windows Server 2019 上使用 Docker
    windows10下安装docker报错:error during connect
    git删除远程分支
    linux下shell显示git当前分支
  • 原文地址:https://www.cnblogs.com/liuqi/p/7204588.html
Copyright © 2011-2022 走看看