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)效果

  • 相关阅读:
    使用Visual Studio .Net 做自己的汉化软件
    给所有的Control加两个属性,实现回车键自动跳转到下一个控件
    数字逗号标记—以前原创(一)
    解决w3wp.exe占用CPU和内存问题
    sql日期函数
    索引的使用总结
    w3wp.exe狂占内存
    w3wp.exe占内存CPU问题 WIN2003 IIS6.0假死现象的分析
    查看Linux系统日志
    linux动态增加LV空间
  • 原文地址:https://www.cnblogs.com/liuqi/p/7204588.html
Copyright © 2011-2022 走看看