Cucumber JUnit 4 @RunWith(Cucumber.class) to JUnit Platform @Suite
org.openrewrite.cucumber.jvm.CucumberRunWithToSuiteArtifactorg.openrewrite.recipe:rewrite-cucumber-jvmReplaces the Cucumber JUnit 4 runner with a JUnit Platform @Suite that runs the Cucumber engine. The @CucumberOptions become @ConfigurationParameter annotations, and the features become @SelectClasspathResource selectors where they are on the classpath. The JUnit 4 runner looks for glue in the package of the annotated class by default, and the Cucumber engine in the whole classpath, so that package becomes the explicit glue when none is configured. Class-level setup and teardown methods become @BeforeSuite and @AfterSuite methods, as a @Suite does not run @BeforeClass or @BeforeAll. A class that extends another class, which may contribute @CucumberOptions, or that has an option that cannot be carried over, such as one that refers to a constant, keeps the JUnit 4 runner, with a comment explaining why.
Add to your build
~/.gradle/gradle.properties
codeGenomeUsername=you@example.com
codeGenomeToken=YOUR_DOWNLOAD_TOKEN
build.gradle.kts
plugins {
id("org.openrewrite.rewrite") version("latest.release")
}
rewrite {
activeRecipe("org.openrewrite.cucumber.jvm.CucumberRunWithToSuite")
}
repositories {
mavenCentral()
maven {
url = uri("https://artifacts.codegenomeproject.org/maven")
credentials {
username = providers.gradleProperty("codeGenomeUsername").get()
password = providers.gradleProperty("codeGenomeToken").get()
}
}
}
dependencies {
rewrite("org.openrewrite.recipe:rewrite-cucumber-jvm:2.20.0")
}
Then run
./gradlew rewriteRunUsage
This recipe has no required configuration options. You’ll need the Moderne CLI configured before running the command below.
mod run . --recipe org.openrewrite.cucumber.jvm.CucumberRunWithToSuiteIf the recipe isn’t available locally, install it with:
mod config recipes jar install org.openrewrite.recipe:rewrite-cucumber-jvm:RELEASEData tables
Structured output this recipe can produce.
- Source files that had resultsSource files that were modified by the recipe run.
org.openrewrite.table.SourcesFileResults - Source files that had search resultsSearch results that were found during the recipe run.
org.openrewrite.table.SearchResults - Source files that errored on a recipeThe details of all errors produced by a recipe run.
org.openrewrite.table.SourcesFileErrors - Recipe performanceStatistics used in analyzing the performance of recipes.
org.openrewrite.table.RecipeRunStats