Maven ‘skip tests’ & test-jar dependency errors

If you use test-jar dependencies in a multi-module Maven project (see my previous posting) you will run into a problem when you run Maven install with the maven.test.skip option turned on.

Problem

Maven looks for dependencies on test-jars even when maven.test.skip is turned on. This posting on the Maven issue tracker site perfectly summarizes the problem.

The maven.test.skip option (which is equivalent to the ‘Skip tests’ checkbox in IntelliJ’s Maven Runner options) prevents test code compilation, packaging and execution.

Hence no test-jars are built and that leads to the dependency error described above.

Solution

Disable the ‘Skip Tests’ checkbox in IntelliJ and INSTEAD add a property skipTests with value true.

This causes all test code to be built (and packaged as test-jars – when configured as described in my last posting) and only disables the execution of the tests.

Maven test execution options

maven.test.skip
Disables both running the tests and compiling the tests.

skipTests
Set this to true to skip running tests, but still compile them

Leave a comment