Is there a way to setup a Maven project to run to ignore a collection of tests by default unless a specific system variable is present?
For example, if I run the following:
mvn clean install
A certain collection of tests are not executed as part of the build. If I execute the build in this way:
mvn clean install -DrunAllTests
The tests that are ignored by default in the standard build are also executed.
I know I can do this using TestNG, but I would prefer to stay with JUnit for now. I also tried using the Junit Categories feature, but could not get the tests to be ignored by default.
Any thoughts or ideas?
To include tests for execution you can add the following configuration for maven-surefire-plugin:
So, you can use this together with Maven profiles, and extract/enable your additional tests in a spacial profile. For example:
Then maven command would look like this:
If you prefer to use properties, you can add activation section to the allTests profile and activate it based on given property.