Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JUnit4 SpringClassRule and SpringMethodRule to SpringExtension #571

Merged
merged 8 commits into from
Aug 14, 2024

Conversation

Laurens-W
Copy link
Contributor

@Laurens-W Laurens-W commented Aug 14, 2024

What's changed?

Added a recipe to migrate from JUnit 4 Spring Rules to JUnit 5 ExtendWith

What's your motivation?

Anything in particular you'd like reviewers to focus on?

Anyone you would like to review specifically?

@timtebeek @FieteO

Have you considered any alternatives or workarounds?

Any additional context

I'm wondering whether there'd be any harm in annotating the class with @SpringBootTest instead of @ExtendWith(SpringExtension.class)

Checklist

  • I've added unit tests to cover both positive and negative cases
  • I've read and applied the recipe conventions and best practices
  • I've used the IntelliJ IDEA auto-formatter on affected files

@Laurens-W Laurens-W self-assigned this Aug 14, 2024
@Laurens-W Laurens-W marked this pull request as ready for review August 14, 2024 15:30
@FieteO
Copy link
Contributor

FieteO commented Aug 14, 2024

Regarding your concern with @SpringBootTest:
I think you are right, there is a difference: @SpringBootTest influences context scanning, while @Extend(SpringExtension.class) doesn't. Having that in mind, using @ExtendWith(...) is the safer thing to do.

@timtebeek timtebeek changed the title Junit4 Spring Rules to SpringExtension JUnit4 SpringClassRule and SpringMethodRule to SpringExtension Aug 14, 2024
Copy link
Contributor

@timtebeek timtebeek left a comment

Choose a reason for hiding this comment

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

Good addition; thanks! Also thanks to @FieteO for the suggestion and helpful context in the review.

@timtebeek timtebeek added recipe Recipe requested boot-2.5 boot-2.4 and removed boot-2.5 labels Aug 14, 2024
@timtebeek timtebeek merged commit 729164f into main Aug 14, 2024
2 checks passed
@timtebeek timtebeek deleted the junit4-spring-rules-to-extension branch August 14, 2024 17:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
boot-2.4 recipe Recipe requested
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

The Junit4to5Migration recipe fails to migrate @ClassRule (of type SpringClassRule)
3 participants