Testng系列-ReportNG

发表于:2017-7-27 15:19

字体: | 上一篇 | 下一篇 | 我要投稿

 作者:琦仔    来源:博客

  生成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里边;

21/212>
《2023软件测试行业现状调查报告》独家发布~

关注51Testing

联系我们

快捷面板 站点地图 联系我们 广告服务 关于我们 站长统计 发展历程

法律顾问:上海兰迪律师事务所 项棋律师
版权所有 上海博为峰软件技术股份有限公司 Copyright©51testing.com 2003-2024
投诉及意见反馈:webmaster@51testing.com; 业务联系:service@51testing.com 021-64471599-8017

沪ICP备05003035号

沪公网安备 31010102002173号