Migrate Spring Boot 2.x projects to JUnit 5 from JUnit 4
MSALThis 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. SpringBoot2JUnit4to5Migrationmod run . --recipe= org. openrewrite. java. spring. boot2. SpringBoot2JUnit4to5MigrationInstall 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.
- JUnit Jupiter migration from JUnit 4.x
- Migrate
@OutputCaptureRuleto@ExtendWith(OutputCaptureExtension.class) - Remove unnecessary Spring
@RunWith - Remove redundant
@ExtendWith(SpringExtension.class) - Replace
@ExtendWithand@ContextConfigurationwith@SpringJUnitConfig - Remove obsolete Spring JUnit runners
- Replace
SpringClassRuleandSpringMethodRulewith JUnit 5SpringExtension - Add Gradle or Maven dependency
org.springframework.boot:spring-boot-tools:2.x