Maven not running all JUnit tests

Feb 20, 2019 by Thibault Debatty - 507 views

https://cylab.be/blog/15/maven-not-running-all-junit-tests

Here is a trick for solving a tricky and vicious maven bug...

If you are using maven to build your java project, with JUnit tests, you may encounter an error where some (or all) of your tests are not executed, without causing any error message.

The reason is that some versions of maven-surefire-plugin, the plugin used by maven to run your junit tests, do not fully support JUnit5:

https://maven.apache.org/surefire/maven-surefire-plugin/featurematrix.html

This has been fixed in maven-surefire-plugin version 2.22.0.

If you are using an autogenerated pom.xml, chance is great that you are using an older version, You can fix this issue by using the latest version of maven-surefire-plugin in your pom.xml (currently 2.22.1):

<build>
    <plugins>
        <plugin>
            <artifactId>maven-surefire-plugin</artifactId>
            <version>2.22.1</version>
        </plugin>
    </plugins>
</build>