Maven (surefire) test plugin excludes not working

巧了我就是萌 提交于 2019-12-04 04:16:15
G. Demecki

Although you already found an answer, there is a simpler solution.

There is no need to use <excludes> tag. Sticking to the maven naming conventions would be enough. Just name your integration tests with *IT suffix (for example: MyClassIT.java) and let maven-failsafe-plugin do its job.

Keep in mind that maven-surefire-plugin is designed to run your unit tests. That's mean all test classes that with the following wildcard patterns:

  1. Test*.java
  2. *Test.java
  3. *TestCase.java

On the other hand, maven-failsafe-plugin is designed to run your integration tests, and will automatically include all test classes with the following wildcard patterns:

  1. IT*.java
  2. *IT.java
  3. *ITCase.java

Your arquillian test is surely an integration test, so renaming it to DocumentChangeSubscriberIT.java would solve all your problems ouf of the box.

btw. this post may also be useful in terms of separation unit tests from the integration tests.

Hope it helps somebody.

Ok, excluding tests works. It was as simple as mispelling my class name: DocumentChangeSubsriberTest.java instead of DocumentChangeSubscriberTest.java.

Sorry.

src3369

Although the question has been resolved, in-case someone is having similar issues with excludes, I am posting this. I had a similar issue where-in my excludes was not working for maven-failsafe-plugin. I was using excludes to exclude running some integration tests.

I was using mvn verify to run integration tests.

in my case,

 <excludes>
   <exclude>**/something/*Test.java</exclude>
</excludes>

DOES NOT work if I use the -Dit.test option
i.e. mvn verify -Dit.test="<some_package>"


however DOES work correctly if I don't specify -Dit.test.
i.e. mvn verify

I had a similar problem, just to throw out another thing for people to look at: My maven-surefire-plugin, as person described above, was accidentally declared under <reporting><plugins><plugin>....</plugin></plugins></reporting> but of course needed to be under <build><plugins><plugin>...</plugin></plugins></build>. The top <reporting> and <build> specs were higher up and off the page so something to verify if anyone gets this same error.

nmartinez

This question was already answer in this thread (or at least a very similar one): How can I skip tests in maven install goal, while running them in maven test goal?

Take a look, it might be helpful! The simple answer is that what you are trying to do it's not an option without using a custom profile (but it's way better explained in that thread).

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!