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.