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 tests from junit4 to junit5 #4322

Open
shoothzj opened this issue Apr 29, 2024 · 6 comments · May be fixed by #4377
Open

Migrate tests from junit4 to junit5 #4322

shoothzj opened this issue Apr 29, 2024 · 6 comments · May be fixed by #4377

Comments

@shoothzj
Copy link
Member

JUnit 5 offers significant improvements over JUnit 4, including more powerful and flexible testing capabilities like annotation-based coding(so we don't need to write assume), parallel test execution, and other features. We can write new test classes using junit5, and existing-test classes can be slowly migrated.

This issue to track tests migrate to junit5, we can migrate a package、a small module gradually.

See also:
https://lists.apache.org/thread/hlyc722gy45s3y61q7n79hdcr6cgrx7v

@sherlock-lin
Copy link
Contributor

@shoothzj Hi shoothzj, I'm very interested in this job, can I have it processed?

@shoothzj
Copy link
Member Author

@sherlock-lin Sure, go ahead, I think we'd better change less than 15 files in one Pull Reuqest.

@sherlock-lin
Copy link
Contributor

@sherlock-lin Sure, go ahead, I think we'd better change less than 15 files in one Pull Reuqest.

Okay, I'll do it in small batches.

@lhotari
Copy link
Member

lhotari commented May 16, 2024

OpenRewrite contains support for Junit4 to Junit5 migration. It's probably worth using it to assist in the migration.
https://docs.openrewrite.org/running-recipes/popular-recipe-guides/migrate-from-junit-4-to-junit-5

I'd also recommend using AssertJ for more complex assertions since the error messages that AssertJ creates are much better than ordinary asserts.

there's also a recipe for migrating to use AssertJ:
https://docs.openrewrite.org/running-recipes/popular-recipe-guides/junit-asserts-to-assertj

@lhotari
Copy link
Member

lhotari commented May 17, 2024

It looks like IntelliJ Ultimate has Junit 4 -> Junit 5 refactoring in the IDE:
image
It doesn't seem very useful since it's not migrating the assertions. That's why OpenRewrite is more practical. There seems to be OpenRewrite recipe support in IntelliJ too.

@sherlock-lin
Copy link
Contributor

OpenRewrite contains support for Junit4 to Junit5 migration. It's probably worth using it to assist in the migration. https://docs.openrewrite.org/running-recipes/popular-recipe-guides/migrate-from-junit-4-to-junit-5

I'd also recommend using AssertJ for more complex assertions since the error messages that AssertJ creates are much better than ordinary asserts.

there's also a recipe for migrating to use AssertJ: https://docs.openrewrite.org/running-recipes/popular-recipe-guides/junit-asserts-to-assertj

Thanks, I needed this so much. : )

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants