Skip to content

Fix #3428: resolve parents via TestPlan.getParent for pre-1.8 platforms - #3429

Merged
olamy merged 2 commits into
apache:masterfrom
kalayciburak:fix/3428-parent-fallback-pre-junit-platform-1.8
Aug 13, 2026
Merged

olamy merged 2 commits into
apache:masterfrom
kalayciburak:fix/3428-parent-fallback-pre-junit-platform-1.8

Conversation

@kalayciburak

@kalayciburak kalayciburak commented Aug 12, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Cucumber scenarios can still report Tests run: 0 when the JUnit Platform on the test classpath is older than 1.8.

RunListenerAdapter walked parents through TestIdentifier.getParentIdObject(), which only exists from Platform 1.8. On older launchers the walk no-ops, scenarios keep the feature display name as sourceName, and TestSetRunListener flushes an empty stats bucket for the runner class.

This switches parent resolution to TestPlan.getParent(TestIdentifier), available since Platform 1.0, for both findTopParent and findFirstParentContainerAndSourceClass.

Fixes #3428

Test plan

  • mvn -pl surefire-providers/surefire-junit-platform test -Dtest=RunListenerAdapterTest - 28/28 GREEN (includes new notifiedWithRunnerClassWhenCucumberScenarioHasNoClassSource)
  • mvn -pl surefire-providers/surefire-junit-platform test - 84/84 GREEN
  • mvn -pl surefire-its -Prun-its -Dit.test=CucumberJUnit4VintageIT verify - GREEN (cucumber-junit + vintage 5.7.2 + platform 1.7.2)

…latforms

Parent walks used TestIdentifier.getParentIdObject(), which is absent
before JUnit Platform 1.8. When that method is missing, Cucumber
scenarios keep feature display names as source and report Tests run: 0.
Use TestPlan.getParent (API since 1.0) instead.
@aghoussaini

Copy link
Copy Markdown
Contributor

@olamy can you take a look at this? We are facing an issue on 3.5.6 which this PR resolves.

@olamy

olamy commented Aug 13, 2026

Copy link
Copy Markdown
Member

Thanks for the PR.
I'm bit curious to see any IT test because the current test for cucumber does not have any issues?
Is there anything you could add as IT test to show it?

The existing cucumber IT stays on Platform 1.13, so it cannot show
Tests run: 0 from the getParentIdObject gate. This fixture uses
cucumber-junit + vintage 5.7.2 + platform 1.7.2.
@kalayciburak

Copy link
Copy Markdown
Contributor Author

yep, current cucumber IT is on 5.13 so it never hits this. added CucumberJUnit4VintageIT on vintage + platform 1.7.2, that's the Tests run: 0 path. pushed

@aghoussaini

Copy link
Copy Markdown
Contributor

This will be on 3.5.7 right? @olamy

@olamy

olamy commented Aug 13, 2026

Copy link
Copy Markdown
Member

This will be on 3.5.7 right? @olamy

this will be merged to master so in the coming 3.6.0-M2.
then will need a follow up for cherry-pick in 3.5.x branch

@olamy olamy added the bug Something isn't working label Aug 13, 2026
@olamy olamy added this to the 3.6.0-M2 milestone Aug 13, 2026
@olamy olamy self-assigned this Aug 13, 2026
@olamy
olamy merged commit 909444c into apache:master Aug 13, 2026
14 checks passed
olamy pushed a commit that referenced this pull request Aug 14, 2026
…r pre-1.8 platforms (#3429) (#3431)

Backport of #3429 (909444c) from master, adapted for 3.5.x.

Parent walks used TestIdentifier.getParentIdObject(), which is absent
before JUnit Platform 1.8. When that method is missing, Cucumber
scenarios keep feature display names as source and report Tests run: 0.
Use TestPlan.getParent (API since 1.0) instead.

Adapted for 3.5.x:
- 3.5.x has no Suite-boundary handling in findTopParent (that landed on
  master after 3.5.x branched), so only the parent-resolution change is
  taken and the surrounding logic is left as-is.
- Only the new notifiedWithRunnerClassWhenCucumberScenarioHasNoClassSource
  unit test is backported; the two Suite-hierarchy tests it sits next to
  on master do not exist here.
- CucumberJUnit4VintageIT uses JUnit 4 annotations, matching the rest of
  surefire-its on this branch.

The new IT covers the regression: the existing cucumber IT stays on
Platform 1.13, so it cannot show Tests run: 0 from the
getParentIdObject gate. This fixture uses cucumber-junit + vintage
5.7.2 + platform 1.7.2.

Co-authored-by: Burak Kalaycı <kalayciburak1996@gmail.com>
@olamy olamy mentioned this pull request Oct 3, 2026
2 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Cucumber scenarios still reported as Tests run: 0 when junit-platform < 1.8 (#828 fix is version-gated)

3 participants