[
https://issues.apache.org/jira/browse/SUREFIRE-1765?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17071706#comment-17071706
]
Tom De Wolf commented on SUREFIRE-1765:
---------------------------------------
[~tibordigana] When I run the build mvn -X test then the current situation is :
{code:java}
[DEBUG] test(compact) classpath: test-classes junit-jupiter-5.6.1.jar
junit-jupiter-api-5.6.1.jar apiguardian-api-1.1.0.jar opentest4j-1.2.0.jar
junit-platform-commons-1.6.1.jar junit-jupiter-params-5.6.1.jar
junit-jupiter-engine-5.6.1.jar junit-platform-engine-1.6.1.jar
[DEBUG] test(compact) modulepath: classes
{code}
Now I tested the following scenarios:
* unit test that does not call the isAnnotationPresent which would fail the
test, i.e. normal modular unit test behaviour without the jdk bug
** mvn -X test runs fine
** when I then copy the exact command line that is executed and remove the
'test-classes' from the classpath manually
*** then the test still runs fine
*** so this indicates that +adding test-classes to the classpath is not
necessary when the test is a modulepath test+ --> best to then not add it on
classpath
* unit test that does call the isAnnotationPresent which would fail the test
** mvn -X test runs but fails on jdk bug
** when I then copy the exact command line that is executed and remove the
'test-classes' from the classpath manually
*** then it still fails, so it would not be a workaround for the jdk bug – is
apparently the case with any module-info.class on the classpath – needs to be
fixed in https://bugs.openjdk.java.net/browse/JDK-8241770.
*** when I move everything to the module path (so no classpath) and add module
surefire.booter as module then I bump into a +split package problem between
surefire.api and surefire.junit.platform+ --> can this be fixed?
****
{code:java}
Error occurred during initialization of boot layer
java.lang.module.ResolutionException: Module surefire.junit.platform contains
package org.apache.maven.surefire.util.internal, module surefire.api exports
package org.apache.maven.surefire.util.internal to surefire.junit.platform{code}
So looking at the above, the bug needs to be fixed in the jdk, but 2 fixes for
surefire are underlined above which can be tackled in this issue?
> target/test-classes should not be added to classpath when tests run on
> modulepath using patch-module
> ----------------------------------------------------------------------------------------------------
>
> Key: SUREFIRE-1765
> URL: https://issues.apache.org/jira/browse/SUREFIRE-1765
> Project: Maven Surefire
> Issue Type: Bug
> Affects Versions: 2.22.1, 2.22.2
> Reporter: Tom De Wolf
> Priority: Major
> Attachments: reproduce-xxxAnnotation-jdk-bug.zip
>
>
> When running junit tests using the maven-surefire-plugin the
> target/test-classes are added as first entry in the classpath.
> However, when testing a explicit java module with a module-info.java the
> test-classes are already part of the module path using --patch-module. So
> they should not be on the classpath?
> In some scenario's this can give unwanted side-effects, i.e. that the same
> classes are on the modulepath and classpath, possibly with a
> module-info.class in both locations (cfr
> [https://bugs.openjdk.java.net/browse/JDK-8241770).]
> So it seems that it is best that target/test-classes is only added to the
> classpath when it is not put on the module-path.
--
This message was sent by Atlassian Jira
(v8.3.4#803005)