测试报告reportng安装与使用

1、reportng源码下载

https://github.com/dwdyer/reportng

2、使用ReportNG生成报告

1)添加依赖,在pom.xml文件中添加下列依赖关系:


<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>

        <dependency>

            <groupId>com.google.inject</groupId>

            <artifactId>guice</artifactId>

            <version>4.0</version>

            <scope>test</scope>

        </dependency>    

2)配置maven-surefire-plugin并加入reportNG listenser

<build>
        <plugins>
        <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>2.17</version>
                <configuration>
                    <suiteXmlFiles>
                        <suiteXmlFile>xmlfile/testng.xml</suiteXmlFile>
                    </suiteXmlFiles>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>2.19.1</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>
                </configuration>
            </plugin>
        </plugins>
    </build>

useDefaultListeners = "false" 用来禁止TestNg产生报告,但是我们还需要他的错误报告testng-fails.xml文件,为了方便我们只关注未通过的测试,所以还要将TestNg的org.testng.reporters.FailedReporter监听器加上。
注:org.uncommons.reportng.HTMLReporter为reportNg的报告监听器

3、示例

发送的参数值

生成的xml报告是用于jenkins使用

附录

1)reportng报告中文乱码包下载地址

http://pan.baidu.com/s/1nunT2mH
密码: w5nv
下载后直接覆盖maven仓库中的包,然后右击eclipse下相应的project操作maven>update project即可,然后运行查看报告

原文地址:https://www.cnblogs.com/seamy/p/15650607.html