-
Notifications
You must be signed in to change notification settings - Fork 73
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
JUnit5's assertInstanceOf is not converted to AssertJ equivalent #607
Comments
Any hint @timtebeek? I saw the pull request from @timo-abele but seems like it didn't work. |
hi @Paulitos ! Thanks for the offer to help; there's (at least) one of two ways we could fix this issue. Refaster style recipeThe best would probably be to extend rewrite-templating to support this particular style of Refaster rule: static final class AssertThatIsInstanceOf<T> {
@BeforeTemplate
void before(Object actual, Class<T> clazz) {
assertInstanceOf(clazz, actual);
}
@AfterTemplate
@UseImportPolicy(STATIC_IMPORT_ALWAYS)
void after(Object actual, Class<T> clazz) {
assertThat(actual).isInstanceOf(clazz);
}
} We already include the refaster rules generated there in our migration from JUnit to AssertJ:
This particular recipe is not converted because of a limitation to handling type parameters in rewrite-templating I haven't yet explored what would be needed for a fix there; I suppose it's more involved and @knutwannheden might have some hints. Imperative recipe supportIf expanding Refaster style recipe support is tough, then we could add an imperative recipe to do the same replacement, similar to the examples seen here: https://github.com/openrewrite/rewrite-testing-frameworks/tree/v2.18.0/src/main/java/org/openrewrite/java/testing/assertj |
What version of OpenRewrite are you using?
I am using the latest version as of 2024-09-21
How are you running OpenRewrite?
originally gradle build file, also verified via PR:
assertInstanceOf
not converted from JUnit5 to assertJ #606What is the smallest, simplest way to reproduce the problem?
full example: https://github.com/openrewrite/rewrite-testing-frameworks/pull/606/files#diff-bfebe6e8e82e88df037959cc55562fae9a10b6b050dd49036be913fd07f93295R45-R70
What did you expect to see?
What did you see instead?
no change
What is the full stack trace of any errors you encountered?
https://github.com/openrewrite/rewrite-testing-frameworks/actions/runs/10971347200/job/30466378864?pr=606#step:5:1500
Are you interested in contributing a fix to OpenRewrite?
No
The text was updated successfully, but these errors were encountered: