原文:https://blog.csdn.net/wwhrestarting/article/details/46596869?utm_source=copy

1.通过maven-surefire-plugin来行maven项目中src/test/java文件夹下的testcase:

默认情况下,testcase的命名规范必须是以下三种之一:

"**/Test*.java" - includes all of its subdirectories and all Java filenames that start with "Test".
"**/*Test.java" - includes all of its subdirectories and all Java filenames that end with "Test".
"**/*TestCase.java" - includes all of its subdirectories and all Java filenames that end with "TestCase

Ps:以上命名规范在pom文件中自定义配置,关键代码如下:

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.18.1</version>
<configuration>
<includes>
<include>Sample.java</include>
</includes>
</configuration>
</plugin>
</plugins>
</build>

2.通过maven-surefire-plugin插件来运行工程目录主路径下的testng.xml(可配置)  

<plugins>
[...]
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.18.1</version>
<configuration>
<suiteXmlFiles>
<suiteXmlFile>testng.xml</suiteXmlFile>
</suiteXmlFiles>
</configuration>
</plugin>
[...]
</plugins>
PS:  .xml文件必须在工程的主目录之下。

3.maven集成reportNG生成Html格式的测试报告:

在pom文件的dependencies中新增三个dependency:
velocity   /guice   /reportng
 
同时修改上述pom文件的maven-surefire-plugin部分代码:
<configuration>
         <suiteXmlFiles>
           <suiteXmlFile>testng.xml</suiteXmlFile>
         </suiteXmlFiles>
         
         <properties>
                <!-- Setting ReportNG listeners -->
        <property>
          <name>listener</name>
          <value>org.uncommons.reportng.HTMLReporter, org.uncommons.reportng.JUnitXMLReporter</value>
        </property>
                         </properties>  
</configuration>

最新文章

  1. Jmeter教程索引
  2. python执行linux的shell命令
  3. TranslateAnimation 使用详解
  4. python遍历文件夹下的文件
  5. msSQL数据库备份还原小结
  6. ffmpeg, libav学习记录
  7. [置顶] ※数据结构※→☆线性表结构(list)☆============单向链表结构(list single)(二)
  8. java web面试技巧,数据库面试,java web轻量级开发面试教程
  9. python小练习之一
  10. 自定义控件辅助神器ViewDragHelper
  11. CentOS_7下安装MySQL
  12. Go语言中的方法和函数
  13. Linux下定时备份文件
  14. JavaScript_02_JavaScript对象
  15. &lt;转载&gt;XML操作
  16. JS中的instanceof和typeof,以及特殊引用类型
  17. ssh 工具
  18. 用ng-style修改元素的color, size等
  19. minSdk(API 26) &gt; deviceSdk(API 19)解决方式
  20. linux socket talkclient talkserver示例

热门文章

  1. 【Java】几种典型的内存溢出案例,都在这儿了!
  2. 【面经分享】互联网寒冬,7面阿里,终获Offer,定级P6+
  3. shiro配置springboot的基本配置
  4. 网鼎杯玄武组部分web题解
  5. GC总结
  6. Java—JSON串转换成实体Bean对象模板
  7. Java IO(十七)FIleReader 和 FileWriter
  8. 我的第一个jQuery插件开发(日期选择器,datePicker),功能还不完善,但用于学习参考已经足够了。
  9. Spring Boot笔记(七) springboot 集成 JavaMail 实现邮箱认证
  10. Java实现 LeetCode 636 函数的独占时间(栈)