Ensure @Nested classes are executed after sibling test methods by marcphilipp · Pull Request #4603 · junit-team/junit-framework (original) (raw)

@marcphilipp self-assigned this

May 31, 2025

sbrannen

@marcphilipp

In order to validate them, classpath scanning was changed to find them in 5.13.0. However, that caused @Nested classes to be added to their parent descriptors before their sibling test methods. This made the order of execution in classes containing nested test classes dependent on how they were discovered unless a MethodOrderer was configured in which case MethodOrderingVisitor ensured test methods came before @Nested test classes on the same level.

This commit changes MethodOrderingVisitor to also ensure this ordering constraint in case no MethodOrderer is configured.

Resolves #4600.

@marcphilipp

@marcphilipp

sbrannen

@marcphilipp marcphilipp deleted the marc/4600-ensure-nested-class-order branch

June 4, 2025 09:44

marcphilipp added a commit that referenced this pull request

Jun 4, 2025

@marcphilipp

In order to validate them, classpath scanning was changed to find them in 5.13.0. However, that caused @Nested classes to be added to their parent descriptors before their sibling test methods. This made the order of execution in classes containing nested test classes dependent on how they were discovered unless a MethodOrderer was configured in which case MethodOrderingVisitor ensured test methods came before @Nested test classes on the same level.

This commit changes MethodOrderingVisitor to also ensure this ordering constraint in case no MethodOrderer is configured.

Resolves #4600.

(cherry picked from commit d0d6071)

This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters

[ Show hidden characters]({{ revealButtonHref }})