Skip to content

Run non-inner @Nested classes to restore backward compatibility - #4700

Merged
marcphilipp merged 1 commit into
mainfrom
marc/4686-run-invalid-non-inner-nested-classes-again
Jul 1, 2025
Merged

marcphilipp merged 1 commit into
mainfrom
marc/4686-run-invalid-non-inner-nested-classes-again

Conversation

@marcphilipp

Copy link
Copy Markdown
Member

Overview

Since the introduction of discovery issues in 5.13, top-level and static
member classes annotated with @Nested were no longer executed because
the validation logic excluded them. This commit restores the old
behavior and improves the generated discovery issues for such cases.

Fixes #4686.


I hereby agree to the terms of the JUnit Contributor License Agreement.


Definition of Done

Since the introduction of discovery issues in 5.13, top-level and static
member classes annotated with `@Nested` were no longer executed because
the validation logic excluded them. This commit restores the old
behavior and improves the generated discovery issues for such cases.

Fixes #4686.
@marcphilipp
marcphilipp force-pushed the marc/4686-run-invalid-non-inner-nested-classes-again branch from ad5aba5 to 3d2b87c Compare June 30, 2025 12:26
@marcphilipp
marcphilipp marked this pull request as ready for review June 30, 2025 12:27
@sormuras

Copy link
Copy Markdown
Member

How is this related to

@sbrannen

sbrannen commented Jun 30, 2025 •

Copy link
Copy Markdown
Member

How is this related to

* [Consider allowing static @Nested classes #4622](https://github.com/junit-team/junit-framework/issues/4622) ?

#4622 is about actually running such static nested classes as part of an overall nested structure, like is currently the case for non-static nested classes -- for parent ExtensionContext behavior, reporting, etc.

Whereas, this issue is simply about allowing static nested classes that are inappropriately annotated with @Nested to be run as stand-alone test classes again.

@marcphilipp
marcphilipp merged commit 442aac1 into main Jul 1, 2025
@marcphilipp
marcphilipp deleted the marc/4686-run-invalid-non-inner-nested-classes-again branch July 1, 2025 08:22
marcphilipp added a commit that referenced this pull request Jul 1, 2025
)

Since the introduction of discovery issues in 5.13, top-level and static
member classes annotated with `@Nested` were no longer executed because
the validation logic excluded them. This commit restores the old
behavior and improves the generated discovery issues for such cases.

Fixes #4686.

(cherry picked from commit 442aac1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Top-level and static classes annotated with @Nested are no longer executed

3 participants