maven 排除某个类,如何在Maven构建中永久排除一个测试类

I'm trying to exclude a single test from my maven build (I don't want the test to be compiled or executed). The following doesn't work:

org.apache.maven.plugins

maven-compiler-plugin

**/MyTest.java

What is the correct way to achieve my goal? I know that I can use the command-line option -Dmaven.test.skip=true, but I would like this to be part of the pom.xml.

解决方案

Skip the test

From the docs, if you want to skip a test, you can use:

org.apache.maven.plugins

maven-surefire-plugin

2.17

**/MyTest.java

See the diference, in your example, you use maven-compiler-plugin, and the docs say that you shoul use maven-surefire-plugin plugin instead.

And, if you want to disable all test, you can use:

true

Also, if you are using JUnit, you can use @Ignore, and add a message.

Exclude the test from compilation

From this answer, you can use. The trick is intercept the default-testCompile

test-compile (default test compile phase) and exclude the class:

org.apache.maven.plugins

maven-compiler-plugin

default-testCompile

test-compile

**/MyTest.java

testCompile

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值