Maven打包时过滤测试代码或指定特定的测试类(maven-surefire-plugin)
1、过滤整个测试代码,可以直接在命令行上指定
mvn clean install -Dmaven.test.skip=true
提示:以上为举例,具体的构建阶段可以自定义,其中maven.test.skip为是否进行测试。
或者
mvn clean install -DskipTests
还可以直接在pom.xml文件上指定,比如使用maven-surefire-plugin时的配置
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.20</version>
<configuration>
<skipTests>true</skipTests>
</configuration>
</plugin>
提示:skipTests当为true为测试,反之同理。如果是使用插件,那么要把依赖的jar包去除。
通过<properties>节点配置属性
<properties>
<skipTests>true</skipTests>
</properties>
或者
<properties>
<maven.test.skip>true</maven.test.skip>
</properties>
2、如果是指定特定的特定的测试类时,此时需要使用maven-surefire-plugin这个插件,因为默认测试使用的就是这个插件进行关联。
官网:http://maven.apache.org/components/surefire/maven-surefire-plugin/
如下pom.xml,指定了测试类及排除某些类
...
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.20</version>
<configuration>
<!-- 包含 -->
<includes>
<include>**/*Tests.java</include>
</includes>
<!-- 排除 -->
<excludes>
<exclude>**/Abstract*.java</exclude>
</excludes>
</configuration>
</plugin>
</plugins>
</build>
...
同样,如果不想指定以上的写法,可以直接在命令行上指定测试类
mvn test -Dtest=[ClassName]
提示:通过命令行就不需要配置pom.xml。
还可以直接指定某个测试类的指定方法(注意:插件要2.8以上,所以还必须指定pom.xml的版本)
mvn test -Dtest=[ClassName]#[MethodName]
[MethodName]为要运行的方法名,支持*通配符,范例:
mvn test -Dtest=MyClassTest#test1
mvn test -Dtest=MyClassTest#*test*
Maven打包时过滤测试代码或指定特定的测试类(maven-surefire-plugin)的更多相关文章
- idea在maven打包时运行Test测试, 导致打包失败, 乱七八糟的错误
在maven打包时运行Test测试, 导致打包失败, 乱七八糟的错误 在maven projects中图标toggle'skip Tests' Mode //宏杰帮助 网上案例:https://blo ...
- eclipse使用maven打包时去掉测试类
eclipse使用maven打包时去掉测试类 在pom.xml文件中增加如下配置: <plugin> <groupId>org.apache.maven.plugins< ...
- maven 打包时mapper.xml打不进去问题
首先,来看下MAVENx项目标准的目录结构: 一般情况下,我们用到的资源文件(各种xml,properites,xsd文件等)都放在src/main/resources下面,利用maven打包时,ma ...
- maven打包时无法加载lib下的jar
© 版权声明:本文为博主原创文章,转载请注明出处 问题描述: 项目在本地部署没有问题,但是使用maven打包时报错: ***(引用jar中某个类的的路径) 不存在 ***(某个java类中的某行某列) ...
- 利用Maven打包时,如何包含更多的资源文件
首先,来看下MAVENx项目标准的目录结构: 一般情况下,我们用到的资源文件(各种xml,properites,xsd文件等)都放在src/main/resources下面,利用maven打包时,ma ...
- 转发:maven打包时始终出现以下提示:-source 1.3 中不支持泛型(请使用 -source 5 或更高版本以启用泛型)
maven打包时始终出现以下提示: 1.-source 1.3 中不支持泛型(请使用 -source 5 或更高版本以启用泛型)List<User> userList= new Array ...
- maven 打包 时出现非法字符: /65279错误
maven 打包 时出现非法字符: /65279错误 碰到的一个问题: 使用下面的命令给工程打包时, maven mvn clean package -Ptest01 -Dmaven.test.ski ...
- idea中 maven打包时时报错User setting file does not exist C:\Users\lenevo\.m2\setting.xml,
第一种错误 :idea中 maven打包时时报错User setting file does not exist C:\Users\lenevo\.m2\setting.xml, 解决方案如下:将ma ...
- 【转载】利用MAVEN打包时,如何包含更多的资源文件
首先,来看下MAVENx项目标准的目录结构: 一般情况下,我们用到的资源文件(各种xml,properites,xsd文件等)都放在src/main/resources下面,利用maven打包时,ma ...
随机推荐
- Fortran学习笔记6(函数、子程序)
子程序Subroutine 自定义函数Function 全局变量COMMON BLOCK DATA 程序代码中,常常会在不同的地方重复用到某一功能和重复某一代码,这个时候就要使用函数.函数包括内嵌函数 ...
- CF-1072-C. Cram Time(贪心,数学)
CF-1072-C. Cram Time http://codeforces.com/contest/1072/problem/C 题意: 第一天有 a 小时,第二天有 b 小时.第 k 个任务需要 ...
- [HIHO] 1050 树中的最长路
#1050 : 树中的最长路 时间限制:10000ms 单点时限:1000ms 内存限制:256MB 描述 上回说到,小Ho得到了一棵二叉树玩具,这个玩具是由小球和木棍连接起来的,而在拆拼它的过程中, ...
- percona-server-5.7二进制安装(tokudb)
1.下载二进制安装包(适用于红帽.centos) https://www.percona.com/downloads/Percona-Server-LATEST/Percona-Server-5.7. ...
- 关于php使用xpath解析html中文乱码问题
$str2 = '<div id="content">我很好 </div>'; $dom = new DOMDocument(); //load之前强转字符 ...
- python基础学习笔记——深浅拷贝
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 lst1 = ["⾦⽑狮王", "紫衫⻰王&qu ...
- 面试准备——rpc面试题
https://www.jianshu.com/p/28e48e5f9c73 1 什么是 RPC ? RPC (Remote Procedure Call)即远程过程调用,是分布式系统常见的一种通信方 ...
- 向php数组添加元素的方法哪种更高效
$arr = array(); // 第一种 array_push($arr, 'test'); // 第二种 $arr[] = 'test'; 参考PHP官方文档:http://php.net/ma ...
- Cookie窃取实验
文章:IE/FIREFOX/CHROME等浏览器保存COOKIE的位置 Chrome的Cookie数据位于:%LOCALAPPDATA%\Google\Chrome\User Data\Default ...
- sql自动审核工具-inception
[inception使用规范及说明文档](http://mysql-inception.github.io/inception-document/usage/)[代码仓库](https://githu ...