Junit 5 tests don't run on maven-confluence-plugin

Hi,

recently we switched to Junit5 in a new plugin project but discovered that the tests are not found in testing lifecycle. Right now we add

@RunWith(JUnitPlatform.class)

on every test class as workaround but want to get rid of that :wink:

I tried to analyze the issue (mvn test -X) and found, that the maven testing lifecycle runs on maven-surefire-plugin 2.12.4 what may be the reason for not running Junit5 tests. The question is, where does this old version come from and how can I fix this? The maven-confluence-plugin should use a newer version and there is no surefire anywhere included as dependency or plugin. Any ideas … ?

[INFO] --- maven-confluence-plugin:6.3.16:unit-test (default-unit-test) @ playground ---
[DEBUG] Configuring mojo com.atlassian.maven.plugins:maven-confluence-plugin:6.3.16:unit-test from plugin realm ClassRealm[extension>com.atlassian.maven.plugins:maven-confluence-plugin:6.3.16, parent: sun.misc.Launcher$AppClassLoader@33909752]
[DEBUG] Configuring mojo 'com.atlassian.maven.plugins:maven-confluence-plugin:6.3.16:unit-test' with basic configurator -->
[DEBUG]   (f) buildTestPlugin = false
[DEBUG]   (f) closureJsCompiler = false
[DEBUG]   (f) encoding = UTF-8
[DEBUG]   (f) excludeAllTestDependencies = false
[DEBUG]   (f) forceUpdateCheck = false
[DEBUG]   (f) offline = false
[DEBUG]   (f) pluginArtifactId = maven-confluence-plugin
[DEBUG]   (f) pluginVersion = 6.3.16
[DEBUG]   (f) project = MavenProject: net.my:playground:1.0.0-SNAPSHOT @ /home/my/project/playground/pom.xml
[DEBUG]   (f) reactor = [MavenProject: net.my:playground:1.0.0-SNAPSHOT @ /home/my/project/playground/pom.xml]
[DEBUG]   (f) session = org.apache.maven.execution.MavenSession@314a31b0
[DEBUG]   (f) skipAllPrompts = false
[DEBUG]   (f) skipAmpsPomCheck = false
[DEBUG]   (f) skipMinifiedJs = false
[DEBUG]   (f) skipUTs = false
[DEBUG]   (f) useFastdevCli = true
[DEBUG]   (f) versionOverrides = []
[DEBUG] -- end configuration --
[DEBUG] Dependency collection stats: {ConflictMarker.analyzeTime=153217, ConflictMarker.markTime=134496, ConflictMarker.nodeCount=132, ConflictIdSorter.graphTime=122339, ConflictIdSorter.topsortTime=44111, ConflictIdSorter.conflictIdCount=27, ConflictIdSorter.conflictIdCycleCount=0, ConflictResolver.totalTime=567491, ConflictResolver.conflictItemCount=77, DefaultDependencyCollector.collectTime=53702972, DefaultDependencyCollector.transformTime=1054908}
**[DEBUG] org.apache.maven.plugins:maven-surefire-plugin:jar:2.12.4:**
[DEBUG]    org.apache.maven:maven-plugin-api:jar:2.0.9:compile
[DEBUG]    org.apache.maven.surefire:surefire-booter:jar:2.12.4:compile
[DEBUG]       org.apache.maven.surefire:surefire-api:jar:2.12.4:compile
[DEBUG]    org.apache.maven.surefire:maven-surefire-common:jar:2.12.4:compile
[DEBUG]       org.apache.commons:commons-lang3:jar:3.1:compile
[DEBUG]       org.apache.maven.shared:maven-common-artifact-filters:jar:1.3:compile
[DEBUG]    org.codehaus.plexus:plexus-utils:jar:3.0.8:compile
[DEBUG]    org.apache.maven:maven-artifact:jar:2.0.9:compile
[DEBUG]    org.apache.maven:maven-project:jar:2.0.9:compile
[DEBUG]       org.apache.maven:maven-settings:jar:2.0.9:compile
[DEBUG]       org.apache.maven:maven-profile:jar:2.0.9:compile
[DEBUG]       org.apache.maven:maven-model:jar:2.0.9:compile
[DEBUG]       org.apache.maven:maven-artifact-manager:jar:2.0.9:compile
[DEBUG]       org.apache.maven:maven-plugin-registry:jar:2.0.9:compile
[DEBUG]       org.codehaus.plexus:plexus-container-default:jar:1.0-alpha-9-stable-1:compile
[DEBUG]          junit:junit:jar:3.8.1:test
[DEBUG]    org.apache.maven:maven-core:jar:2.0.9:compile
[DEBUG]       org.apache.maven:maven-plugin-parameter-documenter:jar:2.0.9:compile
[DEBUG]       org.apache.maven.reporting:maven-reporting-api:jar:2.0.9:compile
[DEBUG]       org.apache.maven:maven-repository-metadata:jar:2.0.9:compile
[DEBUG]       org.apache.maven:maven-error-diagnostics:jar:2.0.9:compile
[DEBUG]       org.apache.maven:maven-plugin-descriptor:jar:2.0.9:compile
[DEBUG]       org.apache.maven:maven-monitor:jar:2.0.9:compile
[DEBUG]       classworlds:classworlds:jar:1.1:compile
[DEBUG]    org.apache.maven:maven-toolchain:jar:2.0.9:compile
[DEBUG]    org.apache.maven.plugin-tools:maven-plugin-annotations:jar:3.1:compile
[DEBUG] Created new class realm plugin>org.apache.maven.plugins:maven-surefire-plugin:2.12.4
[DEBUG] Importing foreign packages into class realm plugin>org.apache.maven.plugins:maven-surefire-plugin:2.12.4

Thanks in advance
Manuel

I would love to know the answer of this too!

Would be nice to have this issue resolved.

Hello, Hi mkummerlaender

As you probably know, for JUnit5 support we need to ensure we have at least 2.22.0 of maven-surefire-plugin.

Now, you are using version 6.13.6 of amps, I see that by default it uses version 2.12.4 of maven-surefire-plugin unless it is overridden Bitbucket

Now comes the question, how do we override that version in amps land ?
I cannot seem to find any documentation for it today, so here is my knowledge of the thing :

<pluginManagement>
            <plugins>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-surefire-plugin</artifactId>
                    <version>2.22.2</version>
                </plugin>
            </plugins>
        </pluginManagement>
        <plugins>
            <plugin>
                <groupId>com.atlassian.maven.plugins</groupId>
                <artifactId>maven-confluence-plugin</artifactId>
                <version>${amps.version}</version>
                <extensions>true</extensions>
                <configuration>
                    <versionOverrides>
                        <versionOverride>maven-surefire-plugin</versionOverride>
                    </versionOverrides>
                    <productVersion>${confluence.version}</productVersion>
                    <productDataVersion>${confluence.data.version}</productDataVersion>

You can derive this configuration by poking around the following code on amps Bitbucket

So this explains how to override plugin versions in the AMPS lifecycle.

Sidenote : I would recommend upgrading your maven-confluence-plugin to version 8.x , as :

  1. it brings in a newer version of maven-surefire-plugin (but it doesn’t matter because now we know how to override its version)
  2. dev loop upgrades are better done frequently

You can find some example code changes in here [noissue] - support for junit5 example · viqueen/devbox@9eeb20d · GitHub

I hope this answers your question

4 Likes