Class BootLoader

java.lang.Object
io.karatelabs.core.BootLoader

public final class BootLoader extends Object
Discovers karate-boot.js (workdir root, then classpath root) and evaluates it once per Suite. The boot file is ext-scripting only — its JS scope is discarded after evaluation; the side effects (exts registered on Suite) are the only output. See AGENT_KARATE.md K43.
  • Field Details

  • Method Details

    • loadIfPresent

      public static BootBinding loadIfPresent(Suite suite, String env)
      Discover + evaluate karate-boot.js for the given Suite. Returns the BootBinding so the caller can surface registered exts on SUITE_ENTER. Returns null when no boot file is present (the common case — boot is opt-in).
      Throws:
      RuntimeException - when boot is present but evaluation fails (Suite must fail loud per K43).
    • bootOnly

      public static BootBinding bootOnly(Path workingDir, String env)
      Boot-only evaluation: run karate-boot.js for a project working dir and return the BootBinding without running any features (no SUITE_ENTER/SUITE_EXIT, no scenarios). The boot side effects — exts constructed + configured via boot.ext(name) + .putMember(...) during the JS eval — are the whole point, so a caller that lives outside a run (e.g. a persistent serve engine re-deriving a project's per-run cov.* config) can reach the booted, configured exts on demand.

      Constructs the minimal Suite the boot phase needs (this package owns the package-private Suite construction, so callers don't have to) anchored at workingDir for both config + boot discovery, then delegates to loadIfPresent(io.karatelabs.core.Suite, java.lang.String). Returns null when workingDir is null or no karate-boot.js is present (the no-ext zero-cost path is preserved).

      Throws:
      RuntimeException - when a boot file IS present but its evaluation fails (fail-loud per K43).