← All recipes
Moderne licensed

Make implausibly long @Timeout values explicit in minutes

Recipe IDorg.openrewrite.java.testing.junit5.ImplausibleTimeoutToMinutes
Artifactorg.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

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:3.43.0

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