I'm building a Maven project with following SureFire configuration:
<plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> <version>${version.maven-surefire-plugin}</version> <configuration> <includes> <include>**/*Test.java</include> </includes> </configuration> </plugin>
Problem is, that when I build it with mvn clean install -DskipTests=true
, the tests are still being executed. What could be the problem?
I tried both -DskipTests
(which is from the Maven website) and -DskipTests=true
, which is added by IntelliJ Idea when I check "skip tests" checkbox.
I don't use any Maven settings.xml
.
EDIT If I comment out the SureFire plugin configuration, the parameter behaves as I expect to. What could be the problem with the configuration above?
You can use Maven tool window to edit the specified patterns. Check the individual files to be ignored during the build. If you have a multi-module project, IntelliJ IDEA lists all POM files of your project. Selecting the checkbox against a POM file will equal ignoring the project or module in the Maven structure.
Take a look at the IntelliJ docs, particularly the Maven Projects Tool Window. Ignore Project / Unignore Project - Choose the Ignore Projects command to ignore project in build, or, on the contrary, include in build the previously ignored project. Ignored projects are not imported into IntelliJ IDEA.
Maven knows two types of parameters for skipping tests:
-Dmaven.test.skip=true
or
-DskipTests=true
The surefire-plugin documentation only mentions the first one, which you have not tried yet.
What you did should work. How to debug this further:
Run mvn help:effective-pom
to see the whole POM that Maven will execute. Search it for test
(case insensitive) to see if there is something odd.
Run mvn test -X
to get debug output. This will print the options used to configure the maven-surefire-plugin
. Make sure you redirect the output to a file!
In the log, you will see
[DEBUG] Configuring mojo 'org.apache.maven.plugins:maven-surefire-plugin:2.15:test' with basic configurator -->
and then, some lines below that:
[DEBUG] (s) runOrder = filesystem [DEBUG] (s) skip = false [DEBUG] (s) skipTests = false
These values mean that tests aren't skipped.
Are you using a recent version of the plugin? Check here. Maybe this option wasn't supported for your version.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With