I added a directory with generated classes to my maven configuration. This causes maven to stop executing tests. Here is the part of the pom.xml which contains the compiler plugin.
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>${compiler-plugin.version}</version>
<configuration>
<compileSourceRoots>
<compileSourceRoot>${project.basedir}/src/main/java</compileSourceRoot>
<compileSourceRoot>${project.basedir}/src/main/resources</compileSourceRoot>
<compileSourceRoot>${project.build.directory}/generated-sources/openapi/src/gen/java</compileSourceRoot>
</compileSourceRoots>
</configuration>
</plugin>
When maven is called (e.g. mvn clean package
), the test phase is executed, but no tests are run.
The problem was, that the configuration is also used in the testCompile phase and so no test classes are compiled. Then surefire finds no tests to execute.
The solution is to change the configuration only in the compile phase:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>${compiler-plugin.version}</version>
<executions>
<execution>
<id>default-compile</id>
<goals>
<goal>compile</goal>
</goals>
<configuration>
<compileSourceRoots>
<compileSourceRoot>${project.basedir}/src/main/java</compileSourceRoot>
<compileSourceRoot>${project.basedir}/src/main/resources</compileSourceRoot>
<compileSourceRoot>${project.build.directory}/generated-sources/openapi/src/gen/java</compileSourceRoot>
</compileSourceRoots>
</configuration>
</execution>
</executions>
</plugin>