← All recipes
Moderne licensed

Make implausibly long @Timeout values explicit in minutes

Recipe IDorg.openrewrite.java.testing.junit5.ImplausibleTimeoutToMinutesArtifactorg.openrewrite.recipe:rewrite-testing-frameworks

JUnit Jupiter's @Timeout defaults to TimeUnit.SECONDS, so a value such as @Timeout(10000) is interpreted as almost three hours, which is most likely a mistake where milliseconds were intended. This recipe rewrites such implausibly large second-based timeouts to the equivalent number of minutes, for instance @Timeout(value = 167, unit = TimeUnit.MINUTES), preserving the original (likely erroneous) semantics while making the mistake far more visible for review.

Single recipeMSAL

Add to your build

Get a download tokenThis recipe is Moderne licensed, so the token must belong to a Moderne customer. It replaces YOUR_DOWNLOAD_TOKEN below.

~/.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.java.testing.junit5.ImplausibleTimeoutToMinutes")
}

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-testing-frameworks:3.47.0")
}

Then run

./gradlew rewriteRun

Usage

This recipe has no required configuration options. You’ll need the Moderne CLI configured before running the command below.

mod run . --recipe org.openrewrite.java.testing.junit5.ImplausibleTimeoutToMinutes

If the recipe isn’t available locally, install it with:

mod config recipes jar install org.openrewrite.recipe:rewrite-testing-frameworks:RELEASE

Options

NameTypeDescription
thresholdSecondsIntegerTimeouts of at least this many seconds (when the time unit is the default SECONDS) are considered implausibly long and are rewritten to the equivalent number of minutes. Defaults to 1000 seconds, about 17 minutes.
e.g. 1000

Data 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