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: java-core #2726

Closed
blakeli0 opened this issue May 3, 2024 · 1 comment · Fixed by #2754
Closed

Migrate Junit 4 to Junit 5: java-core #2726

blakeli0 opened this issue May 3, 2024 · 1 comment · Fixed by #2754
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
@JoeWang1127 JoeWang1127 self-assigned this May 7, 2024
@JoeWang1127 JoeWang1127 added the status: blocked Resolving the issue is dependent on other work. label May 9, 2024
@JoeWang1127
Copy link
Collaborator

JoeWang1127 commented May 9, 2024

Some downstream libraries, e.g., java-logging, depend on a test class, BaseSerializationTest, in java-core.

We should keep these tests as-is.

@JoeWang1127 JoeWang1127 removed the status: blocked Resolving the issue is dependent on other work. label May 10, 2024
JoeWang1127 added a commit that referenced this issue May 16, 2024
Fix #2726.

`BaseSerializationTest` will not migrate to Junit 5 because downstream
libraries, e.g., java-logging, are extending this class and these
libraries still use Junit 4. Migrating this class to Junit 5 will cause
test failures in downstream libraries.
lqiu96 pushed a commit that referenced this issue May 16, 2024
Fix #2726.

`BaseSerializationTest` will not migrate to Junit 5 because downstream
libraries, e.g., java-logging, are extending this class and these
libraries still use Junit 4. Migrating this class to Junit 5 will cause
test failures in downstream libraries.
lqiu96 pushed a commit that referenced this issue May 22, 2024
Fix #2726.

`BaseSerializationTest` will not migrate to Junit 5 because downstream
libraries, e.g., java-logging, are extending this class and these
libraries still use Junit 4. Migrating this class to Junit 5 will cause
test failures in downstream libraries.
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