Skip to content

Conversation

@marcphilipp
Copy link
Member

Overview

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.


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


Definition of Done

Copy link
Member

@sbrannen sbrannen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the quick turnaround on this!

I've added some comments for discussion.

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 force-pushed the marc/4600-ensure-nested-class-order branch from 4d3ba5f to 940a2a5 Compare June 2, 2025 15:13
@marcphilipp marcphilipp requested a review from sbrannen June 2, 2025 15:17
@marcphilipp marcphilipp merged commit d0d6071 into main Jun 4, 2025
13 checks passed
@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
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)
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.

@Nested tests are executed in inverted order when selected via classpath scanning

3 participants