Class Runner

java.lang.Object
io.karatelabs.core.Runner

public final class Runner extends Object
Main entry point for running Karate tests programmatically.

Example usage:

 SuiteResult result = Runner.path("src/test/resources")
     .tags("@smoke")
     .karateEnv("dev")
     .parallel(5);
 
  • Method Details

    • path

      public static Runner.Builder path(String... paths)
      Start building a test run with one or more paths. Paths can be directories or individual .feature files.
    • path

      public static Runner.Builder path(List<String> paths)
      Start building a test run with a list of paths.
    • features

      public static Runner.Builder features(Feature... features)
      Start building a test run with Feature objects.
    • builder

      public static Runner.Builder builder()
      Get a new builder instance.
    • runFeature

      public static FeatureResult runFeature(String path, Map<String,Object> arg)
      Execute a single feature with pre-defined variables. This is called by karate-gatling for running features with Gatling session variables.
      Parameters:
      path - the feature path (can be classpath: prefixed)
      arg - variables to inject into the feature (available as top-level variables)
      Returns:
      the feature result
    • runFeature

      public static FeatureResult runFeature(String path, Map<String,Object> arg, PerfHook perfHook)
      Run a single feature file with arguments and optional PerfHook.

      This method is primarily used by Gatling integration for running features with performance metric collection.

      Parameters:
      path - the feature path (can be classpath: prefixed)
      arg - variables to inject into the feature (available as top-level variables)
      perfHook - optional PerfHook for performance metric collection (Gatling)
      Returns:
      the feature result
    • runFeature

      public static FeatureResult runFeature(String path, Map<String,Object> arg, PerfHook perfHook, List<String> tags)
      Run a single feature file with arguments, optional PerfHook and tag filter.

      This method is primarily used by Gatling integration. The tags argument follows the same semantics as Runner.Builder.tags(String...) — each entry is a tag expression; multiple entries are AND-ed together; commas within an entry are OR.

      Parameters:
      path - the feature path (can be classpath: prefixed)
      arg - variables to inject into the feature (available as top-level variables)
      perfHook - optional PerfHook for performance metric collection (Gatling)
      tags - optional tag filter expressions (null or empty means no filter)
      Returns:
      the feature result
    • runFeature

      public static FeatureResult runFeature(String path, Map<String,Object> arg, PerfHook perfHook, List<String> tags, Runner.Builder template)
      Run a single feature with arguments, optional PerfHook, tag filter, and a pre-configured Runner.Builder template (env, configDir, systemProperties).

      Used by karate-gatling to expose protocol.runner.karateEnv(...) etc. The template's env, configDir, and systemProperties are applied; everything else (paths, listeners, output flags) is overridden for the single-feature, no-report execution model.