I have following configuration in my pom.xml
<build>
<plugins>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.17</version>
<configuration>
<excludes>
<exclude>**/DocumentChangeSubscriberTest.java</exclude>
</excludes>
</configuration>
</plugin>
(...)
DocumentChangeSubscriberTest
is an arquillian test that I want to run only in specified profile.
When I type mvn install
all tests are run, even DocumentChangeSubscriberTest
that I want to exclude.
How to exclude test from the default (anonymous) profile?
I tried <includes><include>...
and it works fine - only included tests were run.
I saw maven surefire test plugin runs tests even if they are excluded: but this is not working for me. I also tried many versions of maven-surefire-plugin
without result. Any ideas?
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,
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
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 letmaven-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:Test*.java
*Test.java
*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:IT*.java
*IT.java
*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.
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.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).
Ok, excluding tests works. It was as simple as mispelling my class name:
DocumentChangeSubsriberTest.java
instead ofDocumentChangeSubscriberTest.java
.Sorry.