Maven fail-safe not executing tests

I had a similar problem. If there aren't any test classes compiled to target/test-classes then check your pom file and ensure that the packaging isn't 'pom'.


Your tests are not in the default test sources directory src/test/java. See:

https://maven.apache.org/guides/introduction/introduction-to-the-standard-directory-layout.html

myModule/src/main/test/java/ClientAccessIT.java

should be:

myModule/src/test/java/ClientAccessIT.java

You could also update your pom file (if you really wanted tests to live in main) to include:

<build>
    <testSources>
        <testSource>
            <directory>src/main/test</directory>
        </testSource>
    </testSources>
</build>

For multi-module projects, the child project needs to have the plugin declared as followed,

 <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-failsafe-plugin</artifactId>
 </plugin>

version inherits from parent pom. Without the above defined, the plugin in parent pom alone will not work.


If you happen to use Spring Boot version 2.4 or higher, and your tests still use JUnit 4, remember to put this dependency:

<dependency>
    <groupId>org.junit.vintage</groupId>
    <artifactId>junit-vintage-engine</artifactId>
    <scope>test</scope>
</dependency>

Version 2.4 of spring-boot-starter-test includes only JUnit 5 and removed the vintage engine that provided a TestEngine for running JUnit 3 and 4 based tests.

Without that vintage engine, all JUnit 4 tests are silently ignored.