(十一)Maven运行TestNG的testcase 两种方式:testng.xml和testngCase.java
2024-08-25 20:52:59
原文: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>
最新文章
- Jmeter教程索引
- python执行linux的shell命令
- TranslateAnimation 使用详解
- python遍历文件夹下的文件
- msSQL数据库备份还原小结
- ffmpeg, libav学习记录
- [置顶] ※数据结构※→☆线性表结构(list)☆============单向链表结构(list single)(二)
- java web面试技巧,数据库面试,java web轻量级开发面试教程
- python小练习之一
- 自定义控件辅助神器ViewDragHelper
- CentOS_7下安装MySQL
- Go语言中的方法和函数
- Linux下定时备份文件
- JavaScript_02_JavaScript对象
- <;转载>;XML操作
- JS中的instanceof和typeof,以及特殊引用类型
- ssh 工具
- 用ng-style修改元素的color, size等
- minSdk(API 26) >; deviceSdk(API 19)解决方式
- linux socket talkclient talkserver示例
热门文章
- 【Java】几种典型的内存溢出案例,都在这儿了!
- 【面经分享】互联网寒冬,7面阿里,终获Offer,定级P6+
- shiro配置springboot的基本配置
- 网鼎杯玄武组部分web题解
- GC总结
- Java—JSON串转换成实体Bean对象模板
- Java IO(十七)FIleReader 和 FileWriter
- 我的第一个jQuery插件开发(日期选择器,datePicker),功能还不完善,但用于学习参考已经足够了。
- Spring Boot笔记(七) springboot 集成 JavaMail 实现邮箱认证
- Java实现 LeetCode 636 函数的独占时间(栈)