JUnit 6
When upgrading to JUnit 6.x, refer to the JUnit 6.0 Release Notes to find out about newly introduced APIs, deprecated APIs, and information about breaking changes.
The io.arconia.rewrite.test.junit.UpgradeJUnit_6 recipe automates most of the changes introduced in JUnit 6.x. You can use it to update your project to the latest JUnit 6.x release.
The recipe will:
-
Upgrade all
org.junit.jupiter:junit-jupiter,junit-jupiter-api,junit-jupiter-engine, andjunit-jupiter-paramsdependencies to the 6.x release line. -
Add the
org.junit.platform:junit-platform-launcherdependency to Gradle’stestRuntimeOnlyconfiguration, which is required at runtime by the JUnit 6 platform. -
Remove the JUnit Platform modules that have been retired in 6:
junit-platform-jfr,junit-platform-runner, andjunit-platform-suite-common.
Run the recipe
You can apply this recipe with any OpenRewrite-compatible tool. The tabs below show three of them: the Arconia CLI, the OpenRewrite Gradle plugin, and the OpenRewrite Maven plugin. See Running Recipes for a comparison of when to pick each one.
-
Arconia CLI
-
Gradle
-
Maven
arconia rewrite run --recipe-name io.arconia.rewrite.test.junit.UpgradeJUnit_6
First, create an init.gradle file in your project root with the following content.
initscript {
repositories {
maven { url "https://plugins.gradle.org/m2" }
}
dependencies {
classpath("org.openrewrite:plugin:latest.release")
}
}
rootProject {
plugins.apply(org.openrewrite.gradle.RewritePlugin)
dependencies {
rewrite("io.arconia.migrations:rewrite-test:latest.release")
}
afterEvaluate {
if (repositories.isEmpty()) {
repositories {
mavenCentral()
}
}
}
configurations.named("rewrite") {
canBeConsumed = false
}
}
Then, run the following command.
./gradlew rewriteRun \
--init-script init.gradle \
-DactiveRecipe=io.arconia.rewrite.test.junit.UpgradeJUnit_6
You can remove the init.gradle file afterwards.
./mvnw -U org.openrewrite.maven:rewrite-maven-plugin:run \
-Drewrite.recipeArtifactCoordinates=io.arconia.migrations:rewrite-test:LATEST \
-Drewrite.activeRecipes=io.arconia.rewrite.test.junit.UpgradeJUnit_6