I've migrated to JUnit 5. In my integration-tests I'm using PowerMock, which unfortunately doesn't support the latest JUnit version yet (see https://github.com/powermock/powermock/issues/830). Therefore I decided to run unit tests with the newer version, which is defined as the default in the parent POM and only run integration tests against JUnit 4. I've tried to override the plugin in the child POM but the tests won't get executed, probably because the tests are not recognized as JUnit 4 tests, so the maven-failsafe-plugin doesn't find any integration-test to execute.
Parent POM:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>3.0.0-M4</version>
<executions>
<execution>
<id>integration-tests</id>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
<configuration>
<argLine>${failsafeOverridableArgLine}
-Djacoco-agent.destfile=${project.build.directory}/coverage-reports/jacoco-it.exec</argLine>
<skipTests>${skip.integration.tests}</skipTests>
<includes>
<include>**/*IntegrationTest.java</include>
</includes>
</configuration>
</execution>
</executions>
</plugin>
...
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<version>5.5.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>5.5.2</version>
<scope>test</scope>
</dependency>
Child POM:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>3.0.0-M4</version>
<executions>
<execution>
<id>integration-tests</id>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
<configuration combine.self="override">
<argLine>${failsafeOverridableArgLine}
-Djacoco-agent.destfile=${project.build.directory}/coverage-reports/jacoco-it.exec</argLine>
<skipTests>${skip.integration.tests}</skipTests>
<includes>
<include>**/*IntegrationTest.java</include>
</includes>
<classpathDependencyExcludes>
<classpathDependencyExclude>org.junit.jupiter:junit-jupiter</classpathDependencyExclude>
<classpathDependencyExclude>org.junit.jupiter:junit-jupiter-engine</classpathDependencyExclude>
</classpathDependencyExcludes>
<additionalClasspathElements>
<additionalClasspathElement>${settings.localRepository}/junit/junit/4.12/junit-4.12.jar</additionalClasspathElement>
</additionalClasspathElements>
</configuration>
</execution>
</executions>
</plugin>
Is this configuration correct?
Problem solved I needed to add the following dependencies to the overriden plugin:
<dependencies>
<dependency>
<groupId>org.apache.maven.surefire</groupId>
<artifactId>surefire-api</artifactId>
<version>3.0.0-M4</version>
</dependency>
<dependency>
<groupId>org.apache.maven.surefire</groupId>
<artifactId>surefire-junit47</artifactId>
<version>3.0.0-M4</version>
</dependency>
</dependencies>
Now the integration-tests run with junit4 while the unit-tests runw with junit5