maven-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Robert Scholte (JIRA)" <>
Subject [jira] [Closed] (SUREFIRE-1420) Support running unit tests in named Java 9 modules
Date Sat, 23 Sep 2017 10:15:00 GMT


Robert Scholte closed SUREFIRE-1420.
    Resolution: Duplicate
      Assignee: Robert Scholte

There is a branch for SUREFIRE-1262 you can try right now. The idea is that once we're confident
with the implementation we'll do a release soon.

> Support running unit tests in named Java 9 modules
> --------------------------------------------------
>                 Key: SUREFIRE-1420
>                 URL:
>             Project: Maven Surefire
>          Issue Type: New Feature
>            Reporter: Gunnar Morling
>            Assignee: Robert Scholte
> As far as I can tell, Surefire will run tests using the traditional classpath also on
Java 9. When the project that is built is a named Java 9 module (i.e. it contains a module
descriptor), it'd be desirable to have a way to run the tests using the module path instead.
> For that, the following things would be required:
> * Adding the currently built project and its dependencies to the module path instead
of the class path when forking the java process running the tests
> * Adding a read edge from the currently built module to the used testing library, e.g.
JUnit, if it's not present as a dependence in the module descriptor already (which it usually
> * Patching the classes from _target/test-classes_ into the currently built module (as
represented by the classes under _target/classes_)
> * Opening up packages containing tests to the testing library so they can be accessed
> I could perform these steps manually by applying the following configuration for the
Surefire plug-in:
> {code}
> <plugin>
>     <groupId>org.apache.maven.plugins</groupId>
>     <artifactId>maven-surefire-plugin</artifactId>
>     <version>2.20.1</version>
>     <configuration>
>         <!-- Don't add any dependencies to the class path -->
>         <classpathDependencyScopeExclude>test</classpathDependencyScopeExclude>
>         <argLine>--module-path=target/classes:/path/to/junit/junit/4.12/junit-4.12.jar:
>                                /path/to/org/hamcrest/hamcrest-core/1.3/hamcrest-core-1.3.jar
>                  --add-modules com.example,junit,hamcrest.core
>                  --add-reads com.example=junit
>                  --add-opens com.example/com.example.internal=junit
>                  --patch-module com.example=target/test-classes</argLine>
>         <!-- Prevents target/classes to be added to the classpath -->         
>         <classesDirectory>path/to/none</classesDirectory>
>         <!-- Doing the same for test classes failed as it caused no tests to be found;
it still works, 
>               I assume the --patch-module above takes precedence over their occurrence
on the classpath -->
>         <!-- <testClassesDirectory>path/to/none</testClassesDirectory>
>     </configuration>
> </plugin>
> {code}
> Ideally, an equivalent {{java}} invocation would be done by Surefire automatically when
building a named module.

This message was sent by Atlassian JIRA

View raw message