[
https://issues.apache.org/jira/browse/SUREFIRE-1755?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17088289#comment-17088289
]
Gili commented on SUREFIRE-1755:
--------------------------------
[~tibordigana] I am using the latest version of TestNG at this time (7.1.0)
which contains a Automatic-Module-Name but no module-info. When running unit
tests, I get:
java.lang.reflect.InaccessibleObjectException: Unable to make public
com.company.internal.MyTest() accessible: module com.company.internal does not
"exports com.company.internal" to unnamed module @36ebc363
I have slightly different expectations from OP but I mostly agree with him.
1. I expect to provide a single module-info.java file (in the src/main/java)
directory.
2. I expect to be able to "export com.company.internal to org.testng" to expose
internal package to unit tests and no one else.
3. I expect Surefire to patch the module path at runtime to ensure that TestNG
runs inside the "org.testng" module
The same logic would work for JUnit.
> Put dependencies from module-info in test sources on module path
> ----------------------------------------------------------------
>
> Key: SUREFIRE-1755
> URL: https://issues.apache.org/jira/browse/SUREFIRE-1755
> Project: Maven Surefire
> Issue Type: Wish
> Components: Maven Surefire Plugin
> Affects Versions: 3.0.0-M4
> Reporter: Stephan van Hulst
> Priority: Minor
>
> When testing a Maven project that contains a {{module-info.java}} in both the
> main source folder and the test source folder, modules that are required for
> testing only (such as {{org.junit.jupiter.api}}) are not put on the module
> path, causing the tests to fail with an exception similar to:
> {code:none}
> java.lang.module.FindException: Module org.junit.jupiter.api not found,
> required by com.example.module{code}
> It would be nice if Surefire patched the module-info in the main source
> folder with extra dependencies from the module-info in the test source folder.
> Example of main {{module-info.java}}:
> {code:java}
> module com.example.module {
> exports com.example.module;
> requires com.example.another.module;
> }{code}
> Example of test {{module-info.java}}:
> {code:java}
> open module com.example.module {
> exports com.example.module;
> requires com.example.another.module;
> requires org.junit.jupiter.api;
> }{code}
> This example implies that {{org.junit.jupiter.api}} would be available on the
> module path during testing, but not during regular compilation and runtime.
--
This message was sent by Atlassian Jira
(v8.3.4#803005)