GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Fixes #3264 : tests inside @Suite incorrectly classified as flakes by mirkoalicastro · Pull Request #3342 · apache/maven-surefire

Conversation

@mirkoalicastro

@mirkoalicastro mirkoalicastro commented Apr 8, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

When rerunFailingTestsCount is used with JUnit Platform @Suite, tests from different classes that share a method name are merged under the Suite class name. It causes real failures to be misclassified as flakes. With the changes in the PR, findTopParent() now stops at engine boundaries (parents with no ClassSource), correctly attributing tests to their actual class while preserving @Nested.

  • New unit test added
  • Verified with the small project shared in the original issue: build correctly fails after fix

Following this checklist to help us incorporate your contribution quickly and easily:

  • Each commit in the pull request should have a meaningful subject line and body.
  • Write a pull request description that is detailed enough to understand what the pull request does, how, and why.
  • Run mvn clean install to make sure basic checks pass. A more thorough check will be performed on your pull request automatically.
  • You have run the integration tests successfully (mvn -Prun-its clean install).

If your pull request is about ~20 lines of code you don't need to sign an
Individual Contributor License Agreement if you are unsure
please ask on the developers list.

To make clear that you license your contribution under
the Apache License Version 2.0, January 2004
you have to acknowledge this by using the following check-box.

  • I hereby declare this contribution to be licenced under the Apache License Version 2.0, January 2004

  • In any other case, please file an Apache Individual Contributor License Agreement.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@mirkoalicastro
mirkoalicastro marked this pull request as ready for review April 8, 2026 19:14
@mirkoalicastro
mirkoalicastro marked this pull request as draft April 8, 2026 19:19
@mirkoalicastro
Fixes apache#3264 : tests inside @suite incorrectly classified as flakes
878db1d
@mirkoalicastro
mirkoalicastro force-pushed the fix/suite-flake-misclassification branch from fabffc2 to 878db1d Compare April 9, 2026 08:53
@mirkoalicastro
mirkoalicastro marked this pull request as ready for review April 9, 2026 08:53
@mirkoalicastro

mirkoalicastro commented Apr 22, 2026

Copy link
Copy Markdown
Contributor Author

Hi @olamy , any chance you could have a look at this? 🙏

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@mirkoalicastro

mirkoalicastro commented Apr 25, 2026

Copy link
Copy Markdown
Contributor Author

@olamy it looks that there are some failures - unrelated to the changes. Would it be fine to proceed?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@olamy

olamy commented Jun 2, 2026

Copy link
Copy Markdown
Member

I have the same failure locally using

Apache Maven 3.9.15 (98b2cdbfdb5f1ac8781f537ea9acccaed7922349)
Maven home: /home/olamy/.sdkman/candidates/maven/current
Java version: 21.0.9, vendor: Eclipse Adoptium, runtime: /home/olamy/.sdkman/candidates/java/21.0.9-tem
Default locale: en_AU, platform encoding: UTF-8
OS name: "linux", version: "6.18.7-76061807-generic", arch: "amd64", family: "unix"

Output

[ERROR] Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 11.15 s <<< FAILURE! -- in org.apache.maven.surefire.its.CucumberIT
[ERROR] org.apache.maven.surefire.its.CucumberIT.simpleCucumberUsage -- Time elapsed: 11.11 s <<< ERROR!
java.lang.RuntimeException: Expecting build failure, have got none!
	at org.apache.maven.surefire.its.fixture.MavenLauncher.executeGoal(MavenLauncher.java:250)
	at org.apache.maven.surefire.its.fixture.MavenLauncher.executeTest(MavenLauncher.java:212)
	at org.apache.maven.surefire.its.CucumberIT.simpleCucumberUsage(CucumberIT.java:52)
	at java.base/java.lang.reflect.Method.invoke(Method.java:580)
	at java.base/java.util.ArrayList.forEach(ArrayList.java:1596)
	at java.base/java.util.ArrayList.forEach(ArrayList.java:1596)
mirkoalicastro reacted with eyes emoji
All reactions
  • 👀 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@mirkoalicastro
Attributes suite tests to enclosing class when nested engines expose …
815c392
…no test class
@mirkoalicastro

mirkoalicastro commented Jun 2, 2026

Copy link
Copy Markdown
Contributor Author

Thanks @olamy. I guess I initially ran the IT with older version than 17. I fixed it and add a unit test for it.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@mirkoalicastro

mirkoalicastro commented Jun 8, 2026

Copy link
Copy Markdown
Contributor Author

@olamy , any chance you could check now that the pipeline is green?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@olamy
olamy requested a review from Copilot August 2, 2026 11:31
Copilot started reviewing on behalf of olamy August 2, 2026 11:31
View session
Copilot AI reviewed Aug 2, 2026
View reviewed changes

Copilot AI left a comment

Copy link
Copy Markdown

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.

Pull request overview

This PR fixes incorrect test attribution when rerunFailingTestsCount is used with JUnit Platform @Suite, where tests from different classes could be merged under the Suite class name (leading to real failures being misclassified as flakes). The change updates RunListenerAdapter.findTopParent() to stop traversal at nested engine boundaries inside Suites so the reported source class remains the real test class (while still falling back to the Suite class for engines that don’t expose class-level sources, e.g., Cucumber).

Changes:

  • Update RunListenerAdapter.findTopParent() to stop at nested engine boundaries inside a Suite when a ClassSource is present.
  • Add unit coverage simulating Suite → nested engine (Jupiter) and Suite → nested engine (Cucumber-like, no ClassSource) hierarchies.
  • Update an integration test expectation to match the new XML report file naming/attribution behavior.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
surefire-providers/surefire-junit-platform/src/main/java/org/apache/maven/surefire/junitplatform/RunListenerAdapter.java Adjusts top-parent detection to avoid attributing nested-engine tests to the enclosing Suite class when a real test class is available.
surefire-providers/surefire-junit-platform/src/test/java/org/apache/maven/surefire/junitplatform/RunListenerAdapterTest.java Adds unit tests covering Suite-with-nested-engine attribution for both Jupiter-style and Cucumber-style hierarchies.
surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1787JUnit45IT.java Updates the expected Surefire XML report filename/classname attribution for the JUnit 5 Suite integration scenario.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
olamy
olamy reviewed Aug 3, 2026
View reviewed changes
Comment thread ...junit-platform/src/main/java/org/apache/maven/surefire/junitplatform/RunListenerAdapter.java
if (lastOpen >= 0) {
int colon = uniqueId.indexOf(':', lastOpen);
if (colon > lastOpen) {
return "engine".equals(uniqueId.substring(lastOpen + 1, colon));

@olamy olamy Aug 3, 2026

Copy link
Copy Markdown
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.

Is there anything less brittle than relying on this?
@sormuras any idea how to identify a node being the engine?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@sormuras sormuras Aug 3, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

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.

Mh, there's no direct API like UniqueId::isEngine in https://docs.junit.org/6.1.2/api/org.junit.platform.engine/org/junit/platform/engine/UniqueId.html ... 🤔

@marcphilipp Any idea?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

olamy reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

@sormuras sormuras Aug 3, 2026

Copy link
Copy Markdown
Contributor

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.

Does this help?

testIdentifier.getUniqueIdObject().getLastSegment().isEngine()

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

olamy reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

@marcphilipp marcphilipp Aug 4, 2026

Copy link
Copy Markdown
Contributor

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.

That should do it

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

olamy reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

@marcphilipp marcphilipp Aug 4, 2026

Copy link
Copy Markdown
Contributor

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.

However, that API was introduced in 6.1.1. You can check for "engine".equals(segment.getType()), though, in earlier versions.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

olamy reacted with thumbs up emoji
All reactions
  • 👍 1 reaction
olamy
olamy requested changes Aug 3, 2026
View reviewed changes
@olamy olamy self-assigned this Aug 6, 2026
@olamy olamy added the bug Something isn't working label Aug 6, 2026
@olamy olamy added this to the 3.6.0-M2 milestone Aug 6, 2026
@olamy
olamy merged commit ce23cec into apache:master Aug 6, 2026
27 of 28 checks passed

Uh oh!

There was an error while loading. Please reload this page.

@olamy olamy mentioned this pull request Aug 28, 2026
Fixing issues of new surefire mode using Junit Platform support-and-care/maven-support-and-care#246
Open
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@sormuras sormuras sormuras left review comments
Copilot code review Copilot
Copilot review effort
Applies to this pull request for everyone.Learn more about Copilot code review.
Copilot left review comments
@olamy olamy olamy requested changes
+1 more reviewer
@marcphilipp marcphilipp marcphilipp left review comments
Reviewers whose approvals may not affect merge requirements

Uh oh!

There was an error while loading. Please reload this page.

Assignees

@olamy olamy

Labels

bug Something isn't working

Projects

None yet

Milestone

3.6.0

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

5 participants

@mirkoalicastro @olamy @marcphilipp @sormuras
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.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.