Package io.karatelabs.core
Class Runner.Builder
java.lang.Object
io.karatelabs.core.Runner.Builder
- Enclosing class:
Runner
-
Method Summary
Modifier and TypeMethodDescriptionbackupOutputDir(boolean enabled) Enable/disable backup of existing output directory.Build the Suite without running it.callOnceCacheStore(Map<String, Map<String, Object>> cacheStore, Map<String, ReentrantLock> lockStore) Inject pre-allocated callOnce/setupOnce stores (keyed by feature URI).callSingleCache(Map<String, Object> cache, ReentrantLock lock) Inject a pre-allocated callSingle cache (and its companion lock).Set the directory containing karate-config.js.consoleLevel(String level) Set the SLF4J/console log level for the "karate" logger.<T> Runner.BuilderdebugSupport(io.karatelabs.js.RunInterceptor<T> interceptor, io.karatelabs.js.DebugPointFactory<T> factory) Set debug support with interceptor and factory.driverProvider(DriverProvider provider) Set a driver provider for managing browser driver lifecycle.dryRun(boolean enabled) Enable dry-run mode (parse but don't execute).Add Feature objects directly.features(Collection<Feature> values) Add Feature objects directly.Provisional API — may change or be removed without notice. Exposed to support advanced runtime scenario discovery (e.g. sequential retry against an expensive grid session) until in-suite orchestration hooks land.httpClientFactory(HttpClientFactory factory) Set the HTTP client factory for custom/mock HTTP clients.Set the karate environment (karate.env).listener(RunListener listener) Add a run event listener.listenerFactory(RunListenerFactory factory) Add a run listener factory for per-thread listeners.listenerFactory(String className) Add a run listener factory by class name (supports no-arg constructor).listeners(Collection<RunListener> values) Add multiple run event listeners.Set the minimum log level for report capture.Set the minimum log level by name (case-insensitive).outputConsoleSummary(boolean enabled) Enable/disable console summary output after test execution.outputCucumberJson(boolean enabled) Enable/disable Cucumber JSON report generation.Set the output directory for reports.Set the output directory for reports.outputHtmlReport(boolean enabled) Enable/disable HTML report generation.outputJsonLines(boolean enabled) Enable/disable JSON Lines streaming output.outputJunitXml(boolean enabled) Enable/disable JUnit XML report generation.parallel(int threadCount) Execute the tests with the specified thread count.Add paths to search for .feature files.Add paths to search for .feature files.pool()Enable browser driver pooling for parallel UI tests.pool(int size) Enable browser driver pooling with explicit pool size.resultListener(ResultListener listener) Add a result listener for streaming test results.resultListeners(Collection<ResultListener> values) Add multiple result listeners.scenarioName(String name) Filter by scenario name (exact match, whitespace-trimmed on both sides).skipTagFiltering(boolean skip) Skip tag filtering (@env, @ignore) so all scenarios run regardless of tags.systemProperty(String key, String value) Set a system property that will be available via karate.properties in scripts.Set tag filter expressions.toString()workingDir(String dir) Set the working directory for relative path resolution.workingDir(Path dir) Set the working directory for relative path resolution.
-
Method Details
-
path
Add paths to search for .feature files. Can be directories or individual files. -
path
Add paths to search for .feature files. -
features
Add Feature objects directly. -
features
Add Feature objects directly. -
karateEnv
Set the karate environment (karate.env). -
tags
Set tag filter expressions. Multiple arguments are AND-ed together (each must match). Commas within a single argument mean OR (any must match).Examples:
tags("@smoke")— run scenarios tagged @smoketags("~@slow")— exclude scenarios tagged @slowtags("@smoke,@fast")— run scenarios tagged @smoke OR @fasttags("~@slow", "~@ignore")— exclude @slow AND @ignoretags("@smoke", "~@slow")— must have @smoke AND must not have @slow
-
scenarioName
Filter by scenario name (exact match, whitespace-trimmed on both sides). When set, only scenarios whose name equals this value will run, and tag filters (@ignore, @env) are bypassed for matches — the same semantics as thefile.feature:LINEline filter. -
configDir
Set the directory containing karate-config.js. -
systemProperty
Set a system property that will be available via karate.properties in scripts. Multiple properties can be set by calling this method multiple times. -
logLevel
Set the minimum log level for report capture. Logs below this level will be filtered from reports. -
logLevel
Set the minimum log level by name (case-insensitive). Valid values: trace, debug, info, warn, error -
consoleLevel
Set the SLF4J/console log level for the "karate" logger. Distinct fromlogLevel(String)which is the report-buffer threshold. Valid values: trace, debug, info, warn, error. If null/unset the level is inherited from logback.xml (typically INFO). -
outputDir
Set the output directory for reports. -
outputDir
Set the output directory for reports. -
workingDir
Set the working directory for relative path resolution. This affects how feature file paths are displayed in reports. -
workingDir
Set the working directory for relative path resolution. This affects how feature file paths are displayed in reports. -
outputHtmlReport
Enable/disable HTML report generation. -
outputJsonLines
Enable/disable JSON Lines streaming output. Streams lifecycle events to karate-json/karate-events.jsonl as they fire, with one record per line and a per-line flush so external tools (e.g. IDE test runners) can tail the file in real time. -
outputJunitXml
Enable/disable JUnit XML report generation. -
outputCucumberJson
Enable/disable Cucumber JSON report generation. -
backupOutputDir
Enable/disable backup of existing output directory. When enabled, the existing output directory is renamed with a timestamp suffix (e.g., karate-reports_2025-01-15_143022) before new reports are written. -
outputConsoleSummary
Enable/disable console summary output after test execution. When disabled, no summary is printed to console, but results are still available in the returned SuiteResult. -
dryRun
Enable dry-run mode (parse but don't execute). -
listener
Add a run event listener. -
listeners
Add multiple run event listeners. -
listenerFactory
Add a run listener factory for per-thread listeners. The factory's create() method is called once per execution thread. -
listenerFactory
Add a run listener factory by class name (supports no-arg constructor). Used for CLI --listener-factory option.- Parameters:
className- fully qualified class name
-
resultListener
Add a result listener for streaming test results. -
resultListeners
Add multiple result listeners. -
driverProvider
Set a driver provider for managing browser driver lifecycle.When set, the provider is used to acquire/release drivers for scenarios instead of creating a new driver per scenario.
Example:
Runner.path("features/") .driverProvider(new PooledDriverProvider()) .parallel(4); // Pool size auto-detected -
pool
Enable browser driver pooling for parallel UI tests. Creates a PooledDriverProvider that reuses browser instances across scenarios.Pool size is auto-detected from the parallel thread count.
Example:
Runner.path("features/") .pool() // Enable pooling .parallel(4); // Pool size = 4 -
pool
Enable browser driver pooling with explicit pool size. Creates a PooledDriverProvider that reuses browser instances across scenarios.Example:
Runner.path("features/") .pool(2) // Pool of 2 browsers .parallel(4); // 4 threads share 2 browsers- Parameters:
size- number of browser instances to pool
-
httpClientFactory
Set the HTTP client factory for custom/mock HTTP clients. When set, this factory is used instead of the default HTTP client. -
skipTagFiltering
Skip tag filtering (@env, @ignore) so all scenarios run regardless of tags. Use this for unit tests that need to run scenarios with any tags. -
debugSupport
public <T> Runner.Builder debugSupport(io.karatelabs.js.RunInterceptor<T> interceptor, io.karatelabs.js.DebugPointFactory<T> factory) Set debug support with interceptor and factory. Used for IDE debugging integration. -
callSingleCache
Inject a pre-allocated callSingle cache (and its companion lock). When set, Suites built from this builder reuse the cache instead of creating their own — so the cache outlives any single Suite. Used by karate-gatling to share callSingle results across the virtual users of one simulation.Pass a matching
lockso all Suites sharing the cache also share its write lock; otherwise concurrent virtual users can race. -
callOnceCacheStore
public Runner.Builder callOnceCacheStore(Map<String, Map<String, Object>> cacheStore, Map<String, ReentrantLock> lockStore) Inject pre-allocated callOnce/setupOnce stores (keyed by feature URI). Same lifetime semantics ascallSingleCache— used by karate-gatling so a feature's callOnce/setupOnce runs once per simulation, not once per virtual user. -
setupOnceCacheStore
-
getResolvedFeatures
Provisional API — may change or be removed without notice. Exposed to support advanced runtime scenario discovery (e.g. sequential retry against an expensive grid session) until in-suite orchestration hooks land.Note: callers that filter the returned
Features themselves (e.g. by walking sections and evaluating aTagSelector) bypassFeatureRuntime.shouldSelectand will miss@ignore,@setup, suite-level line/name filters, and@envnot. Mirror that logic if you need parity with what would actually run. -
parallel
Execute the tests with the specified thread count. This is the terminal operation that runs the tests.- Parameters:
threadCount- number of threads (1 for sequential)- Returns:
- the test results
-
buildSuite
Build the Suite without running it. Useful for advanced scenarios where you need to configure the Suite further or run it manually. -
toString
-