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

Migrate Junit 4 to Junit 5: api-common-java #2727

Closed
blakeli0 opened this issue May 3, 2024 · 0 comments · Fixed by #2779
Closed

Migrate Junit 4 to Junit 5: api-common-java #2727

blakeli0 opened this issue May 3, 2024 · 0 comments · Fixed by #2779
Assignees
Labels
priority: p2 Moderately-important priority. Fix may not be included in next release. type: cleanup An internal cleanup or hygiene concern.

Comments

@blakeli0
Copy link
Collaborator

blakeli0 commented May 3, 2024

See this doc for important differences and benefits of Junit 5.
See the official doc from Junit5 for migration tips.

In general, for each and every unit test

  • If the only change is the package name, change the import statement. For example, replace org.junit.Assert.assertEquals with org.junit.jupiter.api.Assertions.assertEquals.
  • If the feature is still supported, convert the Junit 4 syntax to Junit 5 syntax. For example, replace @Before with @BeforeEach
  • If the feature is not supported anymore, re-write the unsupported part with the alternative. For example, replace @Test(expected = …​) with assertThrows.

See example PR that adds Junit 5 dependencies to gax-java and migrates one test to Junit5.

@mpeddada1 mpeddada1 added type: cleanup An internal cleanup or hygiene concern. priority: p2 Moderately-important priority. Fix may not be included in next release. labels May 6, 2024
@alicejli alicejli self-assigned this May 15, 2024
alicejli added a commit that referenced this issue May 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority: p2 Moderately-important priority. Fix may not be included in next release. type: cleanup An internal cleanup or hygiene concern.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants