Given a Maven project with modules dad and son, where son depends on dad, mvn -am -pl son test runs the tests for dad too. Is there a way to avoid this and only run tests for son module?
Note that there a couple of ways to achieve this, though each has its own caveats which I don't prefer:
- Using
-Dtest="**/son/*Test.java" -DfailIfNoTests=falseoverrides themaven-surefire-pluginconfig in the module. - Similar to
-Dtest, JUnit 5 tags could also be filtered, but this approach suffers from the same shortcoming aforementioned. - One can first do an
install -DskipTests=trueand thenmvn -pl son test, though this pollutes the local Maven repository with partial work.