Class KarateOptionsHandler

java.lang.Object
io.karatelabs.core.KarateOptionsHandler

public final class KarateOptionsHandler extends Object
Applies system-property and environment-variable overrides to a Runner.Builder at the start of parallel(). This preserves the v1 "CI override" contract where Maven/Gradle users pass -Dkarate.options="--tags @smoke" to override a Runner class's hard-coded values without a code change.

Precedence (highest first):

  1. -Dkarate.options="..." system property
  2. KARATE_OPTIONS environment variable (fallback)
  3. Individual sysprops: karate.env, karate.config.dir, with env var fallbacks (KARATE_ENV, KARATE_CONFIG_DIR)
  4. Builder values set programmatically
  5. karate-pom.json values (applied upstream by RunCommand)
  6. Defaults

Implementation reads each override and applies it via the Builder's package-private setters, reusing the v2 CLI grammar through CommandLine.populateCommand(T, java.lang.String...) on a RunCommand instance.

  • Field Details

  • Method Details

    • apply

      public static int apply(Runner.Builder builder, int threadCount)
      Apply sysprop/env overrides to the given Builder. Returns the effective thread count: if karate.options specified --threads N, returns N; otherwise returns the threadCount argument unchanged.
    • applyEnvAndConfigDir

      public static void applyEnvAndConfigDir(Runner.Builder builder)
      Apply only the individual karate.env / karate.config.dir sysprop and environment-variable overrides to the builder — without parsing karate.options. Used by single-feature entry points (e.g. karate-gatling's Runner.runFeature) that build a Suite directly and so never go through apply(io.karatelabs.core.Runner.Builder, int).