Migrate Spring Boot 2.x projects to JUnit 5 from JUnit 4

MSAL

This recipe will migrate a Spring Boot application's tests from JUnit 4 to JUnit 5. This spring-specific migration includes conversion of Spring Test runners to Spring Test extensions and awareness of the composable Spring Test annotations.

org.openrewrite.java.spring.boot2.SpringBoot2JUnit4to5Migration
mod run . --recipe=org.openrewrite.java.spring.boot2.SpringBoot2JUnit4to5Migration

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 Jupiter migration from JUnit 4.x
  2. Migrate @OutputCaptureRule to @ExtendWith(OutputCaptureExtension.class)
  3. Remove unnecessary Spring @RunWith
  4. Remove redundant @ExtendWith(SpringExtension.class)
  5. Replace @ExtendWith and @ContextConfiguration with @SpringJUnitConfig
  6. Remove obsolete Spring JUnit runners
  7. Replace SpringClassRule and SpringMethodRule with JUnit 5 SpringExtension
  8. Add Gradle or Maven dependency org.springframework.boot:spring-boot-tools:2.x