Migrate JUnit asserts to AssertJ

MSAL

AssertJ provides a rich set of assertions, truly helpful error messages, improves test code readability. Converts assertions from org.junit.jupiter.api.Assertions to org.assertj.core.api.Assertions. Will convert JUnit 4 to JUnit Jupiter if necessary to match and modify assertions.

org.openrewrite.java.testing.assertj.JUnitToAssertj
mod run . --recipe=org.openrewrite.java.testing.assertj.JUnitToAssertj

Install it once from Recipe actions, then run it on every repository under the current directory. New to the Moderne CLI? Set it up.

Recipe list

It runs these recipes, in this order.

  1. JUnit 5 best practices
  2. JUnit assertArrayEquals to AssertJ
  3. JUnit assertEquals to AssertJ
  4. JUnit assertFalse to AssertJ
  5. JUnit assertNotEquals to AssertJ
  6. JUnit assertNotNull to AssertJ
  7. JUnit assertNull to AssertJ
  8. JUnit assertSame to AssertJ
  9. JUnit assertTrue to AssertJ
  10. JUnit fail to AssertJ
  11. JUnit AssertThrows to AssertJ exceptionType
  12. Convert try-catch-fail blocks to AssertJ's assertThatThrownBy
  13. JUnit assertInstanceOf to AssertJ
  14. Add Gradle or Maven dependency org.assertj:assertj-core:3.x
  15. Refaster rules that replace JUnit APIs with AssertJ equivalents