您的位置:首页 > 移动开发

使用ReportNg生成测试报告(Maven+Appium+TestNg+ReportNg)

2017-02-08 13:06 387 查看
参考文章:http://blog.csdn.net/wx19900503/article/details/51272971

源起:Maven+Appium+TestNg本就可以实现一个项目的完整测试,但由于TestNg自动生成的测试报告排版较简陋,所以大家都喜欢使用ReportNg。

前提:测试项目已建立,并能正常运行。

Maven项目上集成ReportNg很简单:仅需配置pom.xml即可

1) 添加依赖,在pom.xml中添加如下依赖

<!-- https://mvnrepository.com/artifact/org.uncommons/reportng -->

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

<!-- https://mvnrepository.com/artifact/com.google.inject/guice -->

<dependency>

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

<artifactId>guice</artifactId>

<version>4.0</version>

<scope>test</scope>

</dependency>

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

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

<plugin>

<groupId>org.apache.maven.plugins</groupId>

<artifactId>maven-compiler-plugin</artifactId>

<configuration>

<source>1.8</source>

<target>1.8</target>

</configuration>

</plugin>

3) 更新一下Maven Project,然后右键选中Maven工程,选择Run As->Maven Test,运行成功后,在target目录下创建了一个surefire-reports目录,打开它下面的html文件夹,打开indel.xml,就可以看到相对美观的报告形式:

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: