Skip to content

[SUREFIRE-3446] Fix direct selection of JUnit Jupiter @Nested classes - #3447

Merged
olamy merged 2 commits into
apache:masterfrom
wilx:issue-3446-direct-nested-selection
Aug 28, 2026
Merged

olamy merged 2 commits into
apache:masterfrom
wilx:issue-3446-direct-nested-selection

Conversation

@wilx

@wilx wilx commented Aug 26, 2026 •

Copy link
Copy Markdown
Contributor

Direct selection of a non-static JUnit Jupiter @Nested class stopped
discovering tests after provider-level class-name filters were added. JUnit
needs the enclosing class hierarchy to construct the selected nested test, but
an exact include for the leaf class rejected those enclosing descriptors.

This change derives the actual enclosing hierarchy from Class metadata and
allows those classes through the include filters. It deliberately does not
infer nesting from $ in the binary name, because $ is also legal in a
top-level class name. Existing post-discovery filtering continues to prevent
tests in the enclosing classes or sibling nested classes from running.

The regression coverage includes ordinary and regex includes, a legal
top-level class containing $, and a two-level nested selection whose outer
and intermediate @BeforeEach callbacks must both run. Tests in the outer,
intermediate, and sibling classes fail if selection leaks beyond the requested
leaf.

Fixes #3446

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).

Validation performed with JDK 17:

  • mvn spotless:apply spotless:check
  • mvn -pl surefire-providers/surefire-junit-platform clean install (99 tests)
  • mvn -Prun-its -pl surefire-its -Dit.test=Surefire3446IT clean verify
  • mvn -nsu -Dmaven.build.cache.enabled=false -Prun-its clean install
    (17-module reactor; 776 integration tests, 0 failures, 0 errors)

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.

wilx added 2 commits August 26, 2026 08:48
The direct selection of a JUnit Jupiter @nested class runs no tests on current master, although the same selection runs with Surefire 3.5.4.

Refs apache#3446
Allow the actual enclosing class hierarchy through JUnit Platform class-name filters so a directly selected @nested class can be discovered without broadening test execution. Derive that hierarchy from Class metadata rather than binary-name parsing, and cover ordinary, regex, multi-level lifecycle, sibling, and legal dollar-sign cases.

Fixes apache#3446
@wilx

wilx commented Aug 27, 2026 •

Copy link
Copy Markdown
Contributor Author

Verify / Verify / ubuntu-latest jdk-11-zulu 3.10.0-rc-1 (pull_request) Failing after 47s

This is a failure to download Maven artifact.

@olamy olamy added this to the 3.6.0-M2 milestone Aug 27, 2026
@olamy olamy added the bug Something isn't working label Aug 27, 2026
@olamy
olamy merged commit 45102fa into apache:master Aug 28, 2026
27 of 28 checks passed
@wilx
wilx deleted the issue-3446-direct-nested-selection branch August 31, 2026 13:26
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.

Direct selection of JUnit Jupiter @Nested class runs no tests since 3.6.0-M1

2 participants