-
Notifications
You must be signed in to change notification settings - Fork 917
Maven/Gradle-JUnit Integration: Support nested and toplevel non-public tests and stabiize result extraction #8664
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
matthiasblaesing
merged 7 commits into
apache:master
from
matthiasblaesing:junit-nested
Aug 26, 2025
Merged
Maven/Gradle-JUnit Integration: Support nested and toplevel non-public tests and stabiize result extraction #8664
matthiasblaesing
merged 7 commits into
apache:master
from
matthiasblaesing:junit-nested
Aug 26, 2025
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 tasks
The assumption in the method is, that the names of nested classes are
placed into an index, but that is not the case. In the index only
toplevel classes are recorded. So this:
```
package test;
public class Demo {
static class Nested {}
}
class NonPublic {}
```
will yield:
```
test.NonPublic
test.Demo
```
But the nested class `test.Demo.Nested` will not be found! So use the
index only as a validator if a NestedClass is provided.
60f8cf8 to
98d3071
Compare
mbien
reviewed
Aug 25, 2025
|
|
||
| javac.compilerargs=-Xlint -Xlint:-serial | ||
| javac.source=1.8 | ||
| javac.target=17 |
Member
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
javac.release=17
Contributor
Author
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks - overlooked that. I would have sworn I had that corrected before, oh well 😄
DefaultReplaceTokenProvider looks up NestedClass from invocation context to determine the classname used in tokens. For unittests the NestedClass is passed as part of the SingleMethod so extract it from there.
It was observed, that also for singlethreaded runs the XML reports are sometimes created delayed. The existing retry logic for parallel runs needs to be enhanced to cover the single threaded case and also more than one retry. Observed with a trivial nested testcases at least one retry was observed.
…e to indicate JUnit5 usage This pom.xml runs fine with surefire, but triggers the update surefire/junit warning: ``` <?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>test</groupId> <artifactId>TestNested</artifactId> <version>1.0-SNAPSHOT</version> <packaging>jar</packaging> <properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <maven.compiler.release>17</maven.compiler.release> <exec.mainClass>test.testnested.TestNested</exec.mainClass> </properties> <dependencies> <dependency> <groupId>org.junit.jupiter</groupId> <artifactId>junit-jupiter-api</artifactId> <version>5.13.3</version> <scope>test</scope> <type>jar</type> </dependency> <dependency> <groupId>org.junit.jupiter</groupId> <artifactId>junit-jupiter-params</artifactId> <version>5.13.3</version> <scope>test</scope> <type>jar</type> </dependency> </dependencies> <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> <version>3.5.3</version> </plugin> </plugins> </build> </project> ```
98d3071 to
d21c961
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
ci:dev-build
[ci] produce a dev-build zip artifact (7 days expiration, see link on workflow summary page)
Gradle
[ci] enable "build tools" tests
Java
[ci] enable extra Java tests (java.completion, java.source.base, java.hints, refactoring.java, form)
Maven
[ci] enable "build tools" tests
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
JUnit allows to declare tests on nested (
NestedClass2andDoubleNestedClass3below) and also non public top level classes (PackagedTopLevelNonPublicTest) in addition to the traditional toplevel class tests (test4):In addition to that Unittests can be placed in the default package and support the same set of special cases.
This PR adds support for these cases:
In addition while investigating the fix, it was observed, that the unittest result extraction sometimes yielded an incomplete set. I.e. some of the test data was missing. Analysis showed, that he XML reports from maven surefire were not yet written/updated while the console output was already done.
Another identified problem fixed here was incomplete detection of Jupiter (JUnit5) usage in the unittest run.
It is inspired by the work from @ratcashdev.
Closes: #3975
Closes. #3995