Fix #3303: distinguish JUnit 6 ParameterizedClass invocations - #3432
Open
AzazelSensei wants to merge 2 commits into
Open
Fix #3303: distinguish JUnit 6 ParameterizedClass invocations#3432AzazelSensei wants to merge 2 commits into
AzazelSensei wants to merge 2 commits into
Conversation
@ParameterizedClass uses a [class-template-invocation:#N] unique-id segment and a ClassSource parent. The method legacy name no longer carries [N], so rerunFailingTestsCount merged a pass+fail pair into one flaky name. Append that index to the reported method name, same as we already do for @ParameterizedTest.
There was a problem hiding this comment.
Pull request overview
Fixes rerun aggregation for JUnit 6 parameterized-class invocations by deriving invocation indices from unique IDs.
Changes:
- Appends class-template invocation indices to report names.
- Adds regression coverage for distinct invocations.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
RunListenerAdapter.java |
Extracts and adds invocation indices. |
RunListenerAdapterTest.java |
Tests distinct report names. |
Suppressed comments (1)
surefire-providers/surefire-junit-platform/src/main/java/org/apache/maven/surefire/junitplatform/RunListenerAdapter.java:505
- The suffix check misdetects JUnit 6.1+ names for parameterized methods. Those legacy names already place the class index before the method invocation index; for example, class #1/method #2 is
method()[1][2], so this code appends another[1]and reportsmethod()[1][2][1]. Detect the class-index sequence structurally rather than requiring it at the end, and cover this newer format.
if (classTemplateInvocationIndex != null
&& !methodDesc.endsWith("[" + classTemplateInvocationIndex + "]")) {
methodDesc = methodDesc + "[" + classTemplateInvocationIndex + "]";
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| return null; | ||
| } | ||
| String marker = "[class-template-invocation:"; | ||
| int start = uniqueId.lastIndexOf(marker); |
Collect every class-template-invocation index so nested parameterizations stay distinct. Do not re-append when the legacy name already carries the class index.
Author
olamy
reviewed
Aug 17, 2026
| if (uniqueId == null) { | ||
| return ""; | ||
| } | ||
| String marker = "[class-template-invocation:"; |
Member
There was a problem hiding this comment.
Is there anything available to extract segments from a uniqueId representation rather than parsing manually?
Maybe?
UniqueId.parse(uniqueId).getSegments()
olamy
reviewed
Aug 17, 2026
| boolean hasLegacyDescription = description.startsWith(methodName + '('); | ||
| boolean hasDisplayName = !equalDescriptions || !hasLegacyDescription; | ||
| String methodDesc = parameterized ? description : methodName; | ||
| // JUnit 6.1+ already puts the class index before a method invocation index |
Member
There was a problem hiding this comment.
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Following this checklist to help us incorporate your contribution quickly and easily:
mvn clean installto make sure basic checks pass. A more thorough check will be performed on your pull request automatically.mvn -Prun-its clean install).Targeted module tests:
mvn -pl surefire-providers/surefire-junit-platform test -Dtest=RunListenerAdapterTest,JUnitPlatformProviderTest(75 passed). Did not run the full ITS profile locally.Fixes #3303.
rerunFailingTestsCounttreats two reports with the same class+method name as one test. JUnit 5@ParameterizedTestalready puts[N]on the method legacy name. JUnit 6@ParameterizedClassdoes not: the index lives on a[class-template-invocation:#N]parent with aClassSource, sohasParameterizedParentmisses it and both invocations look liketestSomething(). A fail then a pass on the next index gets collapsed into a flake/pass.This reads that unique-id segment and appends
[N]when the method name does not already have it.