Class Suite

java.lang.Object
io.karatelabs.core.Suite

public class Suite extends Object
Immutable suite configuration and execution engine.

Suite instances can only be created via Runner.Builder. All configuration fields are public final for inspection.

Example usage:

 SuiteResult result = Runner.path("features/")
     .tags("@smoke")
     .parallel(4);
 
  • Field Details

    • KARATE_JSON_SUBFOLDER

      public static final String KARATE_JSON_SUBFOLDER
      Subfolder for JSON output (JSONL events, etc.)
      See Also:
    • features

      public final List<Feature> features
    • env

      public final String env
    • tagSelector

      public final String tagSelector
    • threadCount

      public final int threadCount
    • parallel

      public final boolean parallel
    • dryRun

      public final boolean dryRun
    • configPath

      public final String configPath
    • outputDir

      public final Path outputDir
    • workingDir

      public final Path workingDir
    • outputHtmlReport

      public final boolean outputHtmlReport
    • outputJsonLines

      public final boolean outputJsonLines
    • outputJunitXml

      public final boolean outputJunitXml
    • outputCucumberJson

      public final boolean outputCucumberJson
    • backupReportDir

      public final boolean backupReportDir
    • outputConsoleSummary

      public final boolean outputConsoleSummary
    • systemProperties

      public final Map<String,String> systemProperties
    • listeners

      public final List<RunListener> listeners
    • listenerFactories

      public final List<RunListenerFactory> listenerFactories
    • driverProvider

      public final DriverProvider driverProvider
    • httpClientFactory

      public final HttpClientFactory httpClientFactory
    • skipTagFiltering

      public final boolean skipTagFiltering
    • lineFilters

      public final Map<String,Set<Integer>> lineFilters
    • scenarioName

      public final String scenarioName
    • debugInterceptor

      public final io.karatelabs.js.RunInterceptor<?> debugInterceptor
    • debugPointFactory

      public final io.karatelabs.js.DebugPointFactory<?> debugPointFactory
    • baseResource

      public final io.karatelabs.common.Resource baseResource
    • configResource

      public final io.karatelabs.common.Resource configResource
    • configEnvResource

      public final io.karatelabs.common.Resource configEnvResource
  • Method Details

    • run

      public SuiteResult run()
    • registerExtListener

      public void registerExtListener(Ext ext)
      Register an Ext as a RunListener on this Suite. Called from BootBinding.ext(String) during karate-boot.js evaluation, before SUITE_ENTER fires. Ext will see every event from SUITE_ENTER onward.
    • getWorkingDir

      public Path getWorkingDir()
      Workdir for boot.js discovery + per-ext file resolution.
    • getConfigDir

      public Path getConfigDir()
      The directory of the resolved karate-config.js — for a Java project this is the classpath root (target/test-classes / src/test/resources), since configResource is filesystem-backed even when found via classpath:. The canonical anchor for resolving path references (an ext / boot-config path string), so a project's resources resolve with no classpath: prefix.

      Fallbacks for the cases where karate-config.js is absent: when an explicit configDir was set on the CLI/Runner but holds no config file, the configured directory is still honoured (derived from configPath); when there is no config at all (the default classpath: lookup found nothing), it falls back to workingDir.

    • getBootBinding

      public BootBinding getBootBinding()
      Returns the karate-boot.js BootBinding populated during run(), or null when no boot file is present in the workdir. Surfaced so SuiteRunEvent.toJson() can attach exts[] manifests to SUITE_ENTER — receivers read this to know which exts were active and which embed names to expect.
    • registerChannelFactory

      public void registerChannelFactory(String type, ChannelFactory factory)
      Register a ChannelFactory for an async channel type (e.g. "grpc", "kafka"). Called by an ext from Ext.onBoot(Suite) — typically right after its license gate passes — so karate.channel('grpc') resolves to the ext-supplied factory instead of the io.karatelabs.ext.<type>.<Type>ChannelFactory name-convention fallback. The factory instance is suite-scoped, giving the ext a home for suite/JVM-wide init (shared channels, pools). Last registration for a type wins.
    • getChannelFactory

      public ChannelFactory getChannelFactory(String type)
      Ext-registered ChannelFactory for the given type, or null if none — in which case karate.channel() falls back to the built-in name->FQCN map.
    • registerGlobal

      public void registerGlobal(String name, Object instance)
      Register an ext global under name, seeded into every scenario's JS scope before karate-config.js evaluates. Called by an Ext from Ext.onBoot(Suite); the instance is typically a SimpleObject so members cross into JS natively (no reflection). Throws — and so fails the Suite at boot — when the name is blank or collides with a built-in global (karate, read, match, driver).
    • registerGlobal

      public void registerGlobal(String name, ExtGlobalFactory factory)
      Register a per-scenario ext global: the ExtGlobalFactory is invoked once per scenario at seed time to mint a fresh instance bound with the scenario's KarateJsContext. Prefer this over the singleton registerGlobal(String, Object) when the global carries per-scenario mutable state or needs runtime / path access — see ExtGlobalFactory.
    • getGlobal

      public Object getGlobal(String name)
      The ext global registered under name, or null if none.
    • getGlobals

      public Map<String,Object> getGlobals()
      Immutable view of all ext globals, in registration order.
    • registerReportAssets

      public void registerReportAssets(ReportAssets assets, ClassLoader classLoader)
      Register an ext's report-asset contribution. Called by an Ext from Ext.onBoot(Suite) with a fluent ReportAssets spec, e.g. suite.registerReportAssets(ReportAssets.named("image").js("static/ext.js"), getClass().getClassLoader()). Validates the spec against the classloader (referenced resources must exist); any failure throws and so fails the Suite loud at boot (see EXT.md § Report assets).
    • getReportAssets

      public Map<String,ReportAssets> getReportAssets()
      Immutable view of all registered ext report-asset specs, in registration order.
    • addSummaryCard

      public void addSummaryCard(Map<String,Object> card)
      Contribute one KPI summary card to the summary-page hero (a key/value tile, e.g. {label:'Coverage', value:'53%', sub:'8/15 endpoints'}). Called by an Ext from Ext.onShutdown() (the values are post-run), which the run loop invokes before the report listener writes the summary, so cards are inlined into the page. Optional keys the renderer understands: sub (a second line), href (click-through), and status (ok/warn/fail, for accent colour).
    • getSummaryCards

      public List<Map<String,Object>> getSummaryCards()
      The contributed KPI summary cards, in registration order (empty when no ext added any).
    • fireEvent

      public boolean fireEvent(RunEvent event)
    • getOutputDir

      public String getOutputDir()
    • getCallSingleCache

      public Map<String,Object> getCallSingleCache()
    • getCallSingleLock

      public ReentrantLock getCallSingleLock()
    • getCallOnceCache

      public Map<String,Object> getCallOnceCache(String featureKey)
      Get the callOnce cache for the given feature key (its resource URI). The cache is created on first access and reused across all FeatureRuntimes for the same feature within this Suite — and across Suites when the underlying store was injected via Runner.Builder.
    • getCallOnceLock

      public ReentrantLock getCallOnceLock(String featureKey)
    • getSetupOnceCache

      public Map<String,Object> getSetupOnceCache(String featureKey)
    • getLockManager

      public ScenarioLockManager getLockManager()
    • getScenarioExecutor

      public ExecutorService getScenarioExecutor()
    • getScenarioSemaphore

      public Semaphore getScenarioSemaphore()
    • acquireLane

      public void acquireLane()
    • releaseLane

      public void releaseLane()
    • getCurrentLaneName

      public String getCurrentLaneName()
    • abort

      public void abort()
    • isAborted

      public boolean isAborted()
    • getResult

      public SuiteResult getResult()
    • getResultListeners

      public List<ResultListener> getResultListeners()
    • getSystemProperties

      public Map<String,String> getSystemProperties()
      Get system properties for karate.properties.
    • getDriverProvider

      public DriverProvider getDriverProvider()
    • getPerfHook

      public PerfHook getPerfHook()
    • getHttpClientFactory

      public HttpClientFactory getHttpClientFactory()
    • isPerfMode

      public boolean isPerfMode()
    • isSkipTagFiltering

      public boolean isSkipTagFiltering()