Skip to content

Consider updating testing examples to use JUnit Jupiter #10934

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

Closed
sbrannen opened this issue Mar 4, 2022 · 3 comments
Closed

Consider updating testing examples to use JUnit Jupiter #10934

sbrannen opened this issue Mar 4, 2022 · 3 comments
Assignees
Labels
in: docs An issue in Documentation or samples status: backported An issue that has been backported to maintenance branches type: enhancement A general enhancement
Milestone

Comments

@sbrannen
Copy link
Member

sbrannen commented Mar 4, 2022

The reference currently uses JUnit 4 in testing examples -- for example, Setting Up MockMvc and Spring Security.

Consider updating testing examples to use JUnit Jupiter in line with Spring Boot and other Spring portfolio projects.

@sbrannen sbrannen added status: waiting-for-triage An issue we've not yet triaged type: enhancement A general enhancement labels Mar 4, 2022
@nor-ek
Copy link
Contributor

nor-ek commented Mar 6, 2022

I can take this task.
But I've got some questions. Should we still use @RunWith or replace by @ExtendsWith? If We are going to use @RunWith then we need to use SpringRunner and task should be done.
Another question is about @SpringBootTest, what do you think about using it? Then rest of annotations are unnecessary.

@sbrannen
Copy link
Member Author

sbrannen commented Mar 6, 2022

Should we still use @RunWith or replace by @ExtendsWith? If We are going to use @RunWith then we need to use SpringRunner and task should be done.

No. @RunWith is JUnit 4, and the SpringRunner is Spring's integration with JUnit 4.

Another question is about @SpringBootTest, what do you think about using it? Then rest of annotations are unnecessary.

Correct, @SpringBootTest is meta-annotated with @ExtendWith(SpringExtension.class). So I would suggest that example test classes are either annotated with @ExtendWith(SpringExtension.class) or @SpringBootTest, but I'll let the Spring Security team decide which they prefer.

@sjohnr
Copy link
Contributor

sjohnr commented Mar 9, 2022

Thanks @sbrannen.

Another question is about @SpringBootTest, what do you think about using it? Then rest of annotations are unnecessary.

Correct, @SpringBootTest is meta-annotated with @ExtendWith(SpringExtension.class). So I would suggest that example test classes are either annotated with @ExtendWith(SpringExtension.class) or @SpringBootTest, but I'll let the Spring Security team decide which they prefer.

I don't believe we would want to use @SpringBootTest in Spring Security. For documentation, I suppose it could be less strict, but unless there is already a precedent, perhaps we don't want to introduce that now.

Thanks for volunteering, @nor-ek!

@sjohnr sjohnr added in: docs An issue in Documentation or samples and removed status: waiting-for-triage An issue we've not yet triaged labels Mar 9, 2022
nor-ek added a commit to nor-ek/spring-security that referenced this issue Mar 22, 2022
- replace Before with BeforeEach
- replace RunWith with ExtendWith

Closes spring-projectsgh-10934
jzheaux added a commit that referenced this issue May 27, 2022
Use spring-framework-reference-url placeholder

Issue gh-10934
jzheaux added a commit that referenced this issue May 27, 2022
Point to updated Spring Reference

Issue gh-10934
@jzheaux jzheaux added this to the 6.0.0-M6 milestone May 27, 2022
jzheaux pushed a commit that referenced this issue May 27, 2022
- replace Before with BeforeEach
- replace RunWith with ExtendWith

Closes gh-10934
jzheaux added a commit that referenced this issue May 27, 2022
Use spring-framework-reference-url placeholder

Issue gh-10934
jzheaux added a commit that referenced this issue May 27, 2022
Point to updated Spring Reference

Issue gh-10934
jzheaux added a commit that referenced this issue May 27, 2022
jzheaux pushed a commit that referenced this issue May 27, 2022
- replace Before with BeforeEach
- replace RunWith with ExtendWith

Closes gh-10934
jzheaux added a commit that referenced this issue May 27, 2022
Use spring-framework-reference-url placeholder

Issue gh-10934
jzheaux added a commit that referenced this issue May 27, 2022
Point to updated Spring Reference

Issue gh-10934
jzheaux pushed a commit that referenced this issue May 27, 2022
- replace Before with BeforeEach
- replace RunWith with ExtendWith

Closes gh-10934
jzheaux added a commit that referenced this issue May 27, 2022
Use spring-framework-reference-url placeholder

Issue gh-10934
jzheaux added a commit that referenced this issue May 27, 2022
Point to updated Spring Reference

Issue gh-10934
@jzheaux jzheaux added the status: backported An issue that has been backported to maintenance branches label May 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: docs An issue in Documentation or samples status: backported An issue that has been backported to maintenance branches type: enhancement A general enhancement
Projects
None yet
Development

No branches or pull requests

4 participants