-
Notifications
You must be signed in to change notification settings - Fork 82
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
Enable JUnitAssertXXXToAssertThat for JUnit 4 #672
Comments
hi @kthoms ; thanks for pointing out that it wasn't immediately clear the recipe indeed also upgrades you to JUnit 5. I feel it might be complicated to update all recipes to also support JUnit 4, since there's also steps invoked that first apply JUnit 5 best practices to achieve a more idiomatic migration to AssertJ assertions. rewrite-testing-frameworks/src/main/resources/META-INF/rewrite/assertj.yml Lines 453 to 482 in fc9d8b4
It's been 7,5 years since JUnit 5 came out, and JUnit 6 is on the horizon for the end of this year. Since you're already eyeing JUnit 5, perhaps we should then not complicate the recipes here? Note that you can still develop and run those recipes yourself, but adoption into OpenRewrite might complicate what we have to maintain going forward. |
I leave the decision up to you. For me it is important to migrate the assertions before actually upgrading to JUnit 5. The recipe that converts to JUnit 5 simply breaks too much stuff in our code base. So I want to take this step first. But I can use the recipes for our purpose now, of course. |
What problem are you trying to solve?
I want to migrate JUnit 4 assertions to AssertJ. The existing recipes migrate only JUnit 5 assertions. From the recipe's description it is also not clear that "JUnit
assertEquals
to AssertJ" refer to JU 5 only.Describe the solution you'd like
The existing recipes might be enhanced to cover both cases by trying to match methods for
org.junit.jupiter.api.Assertions
ororg.junit.Assert
and resolve the parameters differently. The assertions are quite similar except for the order of arguments.Have you considered any alternatives or workarounds?
There could be also dedicated JUnit4AssertXXXToAssertThat recipes. This would likely produce more duplicated code.
Migrating to JUnit 5 is the ultimate goal, but I would like to do it stepwise and migrate the assertions before migrating the tests themselves.
Are you interested in contributing this feature to OpenRewrite?
Yes, I have a working draft for one recipe already. I could contribute this already, but it feels as if all JUnitAssertXXXToAssertThat recipses should be enhanced together. Might be surprising if only one recipe behaves different.
The text was updated successfully, but these errors were encountered: