修改后的测试结果:

idea+maven+testNG,设置reportNG

比默认的result好看很多,配置步骤如下:

先在pom.xml中添加一下代码:

<!-- 依赖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>4.0</version>
  <scope>test</scope>
</dependency>
<dependency>
  <groupId>velocity</groupId>
  <artifactId>velocity-dep</artifactId>
  <version>1.4</version>
</dependency>
<dependency>
  <groupId>log4j</groupId>
  <artifactId>log4j</artifactId>
  <version>1.2.17</version>
</dependency>

<!-- 添加插件,添加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>
最后,在testNG.xml中加入:

<!--<listeners>-->
<!--<listener class-name="org.uncommons.reportng.HTMLReporter" />-->
<!--<listener class-name="org.uncommons.reportng.JUnitXMLReporter" />-->
<!--</listeners>-->
去掉注释;也可以在testNG中设置:

idea+maven+testNG,设置reportNG

相关文章:

  • 2021-05-13
  • 2021-08-28
  • 2021-12-26
  • 2021-10-16
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-01-06
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-11-23
相关资源
相似解决方案