Apache Maven 1.x has reached its end of life, and is no longer supported. For more information, see the announcement. Users are encouraged to migrate to the current version of Apache Maven.

Maven Test Plugin

This plug-in provides your basic JUnit testing facilities.


Be careful, the following plugins must be installed to use version 1.8 of the test plugin:

  • maven-jar-plugin 1.8 (at least)

Backward compatibility issue with version 1.8

Version 1.8 of the test plugin removed a prereq on java:compile & java:jar-resources from the test:test goal for optimization reasons (see MPTEST-46). This introduced a backward compatibility issue (see MPTEST-66) which might affect you if the following conditions are met:

  • You either use maven.test.skip=true or your project has no unit tests.
  • Either your project, or a plugin that you use, relies on java sources to be compiled by calling the test:test goal.

An illustration of the problem is provided by the javaapp sourceforge plugin, whose javaapp:jar goal has a prereq on test:test, relying on the java sources to be compiled by this call. If you are calling this goal now with a project that has no tests, the build will fail.

The problem should really be fixed in the corresponding plugin, but a simple workaround is to add the missing goals as a preGoal in your maven.xml:

<preGoal name="javaapp:jar">
  <j:if test="${unitTestSourcesPresent != 'true' or context.getVariable('maven.test.skip') == 'true'}">
    <attainGoal name="java:compile"/>
    <attainGoal name="java:jar-resources"/>

If you don't know the goal that is causing the trouble, you may add the preGoal to test:test, but this might lead to double compilation.