Maven - test jar


A test jar is a jar file used to share test code between module.


In two steps:

Creation of the test jar

  • Creating the test jar that is shared with the other modules (ie all test class will be package in a test jar)

Adding it as a dependency

  • Then in the module that uses this class, add it as dependency

Using <classifier>tests</classifier> instead of <type>test-jar</type> will not work during a reactor build of the test JAR module and any consumer if a lifecycle phase prior to install is invoked. In such a scenario, Maven will not resolve the test JAR from the output of the reactor build but from the local/remote repository.

Documentation / Reference

Powered by ComboStrap