Are you aware of OpenRewrite and it's AssertJ recipes? #2859
Replies: 2 comments
-
I'm aware (but it slipped out of my radar tbh) and I agree it's a better approach than shell scripts. It would be great if you can contribute to it :) Let us know if you need support, we'll do our best in our variable/limited capacity. Anyway thanks for bringing that topic up, appreciated. |
Beta Was this translation helpful? Give feedback.
-
This might help you with this I'm sure is not perfect, but a step on the right way |
Beta Was this translation helpful? Give feedback.
-
There is meanwhile a rather generic and IDE independent refactoring tool: https://docs.openrewrite.org/. It also has a set of transformations for migration from JUnit Assertions to AssertJ: https://docs.openrewrite.org/reference/recipes/java/testing/assertj/junittoassertj, which you can run via Maven (within a build or standalone command line) or Gradle.
I've been using it successfully for migrating some projects. I haven't compared the quality and completeness of its transformation versus the AssertJ scripts yet, but I would expect that given enough contributions and time a solution based on abstract syntax trees should always be more correct than regular expression based things. That's why I'm hereby trying to make more people aware of it and giving it a try.
Slightly different topic: While the JUnit receipes collection already has several cleanups for transforming to more specialized assertion, that is still missing for AssertJ completely. I've been thinking about contributing such transformations (like
assertThat(foo).isEqualTo(true))
->assertThat(foo).isTrue()
) to OpenRewrite (I hope for some spare time during Christmas time). Or is anyone already working on such stuff?Beta Was this translation helpful? Give feedback.
All reactions