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)位置

testng系列-ReportNG

2)效果

testng系列-ReportNG

testng系列-ReportNG

上一篇:2017 年度码云新增项目排行榜 TOP 50,为它们打“call”


下一篇:使用自定义指标进行Pod弹性伸缩