-
Notifications
You must be signed in to change notification settings - Fork 893
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
Open
matthiasblaesing
wants to merge
7
commits into
apache:master
Choose a base branch
from
matthiasblaesing:junit-nested
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
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
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.
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> ```
2 tasks
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 (
NestedClass2
andDoubleNestedClass3
below) 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