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.Set the directory containing karate-config.js.<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.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 -
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. Writes feature results to karate-results.jsonl as they complete. -
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. -
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
-