apache / apache/maven-surefire
[SUREFIRE-1755] Put dependencies from module-info in test sources on module path
- Dominant language
- Java
- Stars
- 461
- Forks
- 588
- Avg merge
- 1d 8h
- Merged PRs (30d)
- 19
Description
**[Stephan van Hulst](https://issues.apache.org/jira/secure/ViewProfile.jspa?name=nibsi)** opened **[SUREFIRE-1755](https://issues.apache.org/jira/browse/SUREFIRE-1755?redirect=false)** and commented
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:
```none
java.lang.module.FindException: Module org.junit.jupiter.api not found, required by com.example.module
```
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`:
```java
module com.example.module {
exports com.example.module;
requires com.example.another.module;
}
```
Example of test `module-info.java`:
```java
open module com.example.module {
exports com.example.module;
requires com.example.another.module;
requires org.junit.jupiter.api;
}
```
This example implies that `org.junit.jupiter.api` would be available on the module path during testing, but not during regular compilation and runtime.
---
**Affects:** 3.0.0-M4
1 votes, 4 watchers
Contributor guide
Research direction
Start by reproducing the issue with a minimal Maven project containing module-info.java in both main and test sources, using org.junit.jupiter.api as a test-only requirement. Trace how Surefire assembles the test module path and verify that the test dependency is available there without becoming part of regular compilation or runtime.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- build-system, testing
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 52/100