apache / apache/maven-surefire

[SUREFIRE-1919] JUnit test discovery fails with reuseForks=false but works when reuseForks=true

Open
#2,931 2 comments 0 reactions 0 assignees View on GitHub
bug priority:major
Dominant language
Java
Stars
461
Forks
588
Avg merge
1d 8h
Merged PRs (30d)
19

Description

**[Jan Mosig](https://issues.apache.org/jira/secure/ViewProfile.jspa?name=jamodd)** opened **[SUREFIRE-1919](https://issues.apache.org/jira/browse/SUREFIRE-1919?redirect=false)** and commented

Hi there,

the other day I was playing around with incubator code from JDK16 and noticed odd behavior wrt the reuseForks configuration.

 

In order to compile and run tests, my project needs the jdk.incubator.foreign module. So I configured it like this:

```java

org.apache.maven.plugins
maven-surefire-plugin

false
1
-Dforeign.restricted=permit --add-modules=jdk.incubator.foreign

```

Which results in

```
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:3.0.0-M5:test (default-test) on project de.itemis.mosig.sfrf: Execution default-test of goal org.apache.maven.plugins:maven-surefire-plugin:3.0.0-M5:test failed: org.junit.platform.commons.JUnitException: TestEngine with ID 'junit-jupiter' failed to discover tests: ClassSelector [className = 'de.itemis.mosig.sfrf.AppTest'] resolution failed: jdk/incubator/foreign/MemoryLayout: jdk.incubator.foreign.MemoryLayout -> [Help 1]
```

Whereas setting `reuseForks` to `true` works.

Please note that the project itself is not modularized, i. e. it does not have a module-info.java specification (on purpose).

I provided a demo for this over at GitHub: https://github.com/JanMosigItemis/sfrf

Any thoughts?

---

**Affects:** 3.0.0-M5

Contributor guide

Open the contributing guide

Research direction

Start with the linked demo project and its Maven Surefire configuration, running the JUnit test with reuseForks=false and then reuseForks=true. Compare forked test discovery and module arguments; done means the JUnit test is discovered successfully with reuseForks=false while retaining the shown incubator-module setup.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
build-system, testing
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.