Class BootLoader
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 Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionstatic BootBindingBoot-only evaluation: runkarate-boot.jsfor a project working dir and return theBootBindingwithout running any features (noSUITE_ENTER/SUITE_EXIT, no scenarios).static BootBindingevalIfPresent(Suite suite, Path bootstrapWorkingDir, String env) Discover + evaluatekarate-boot.jsfor a Suite under construction — called from theSuiteconstructor, before config discovery and feature resolution, becauseboot.classpath(dir)is what both of those honour.
-
Field Details
-
BOOT_FILE_NAME
- See Also:
-
-
Method Details
-
evalIfPresent
Discover + evaluatekarate-boot.jsfor a Suite under construction — called from theSuiteconstructor, before config discovery and feature resolution, becauseboot.classpath(dir)is what both of those honour. Returns theBootBindingso the Suite can read the declared mapping and later surface registered exts onSUITE_ENTER. Returnsnullwhen no boot file is present (the common case — boot is opt-in).The boot file lives at the project root — and discovery only ever looks where the USER named the project:
bootstrapWorkingDir(the explicitly-set working dir, else the explicitly-set config dir, else the process CWD), then the real classpath. It deliberately does NOT follow the classloader-probedSuite.getRoot(): a Java project's root istarget/test-classes, and booting a file that landed there as a copied resource would change behaviour for a project that never asked for it. It also cannot depend onsuite.getWorkingDir()— that is assigned after boot, precisely because boot may re-anchor it.- Parameters:
suite- the Suite being constructed —getRoot()is already finalbootstrapWorkingDir- where to look for the boot fileenv- thekarate.envvalue, exposed asboot.env- Throws:
RuntimeException- when boot is present but evaluation fails (Suite must fail loud per K43).
-
bootOnly
Boot-only evaluation: runkarate-boot.jsfor a project working dir and return theBootBindingwithout running any features (noSUITE_ENTER/SUITE_EXIT, no scenarios). The boot side effects — exts constructed + configured viaboot.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-runcov.*config) can reach the booted, configured exts on demand.Constructs the minimal
Suitethe boot phase needs (this package owns the package-private Suite construction, so callers don't have to) anchored atworkingDir, and returns the binding the Suite constructor already evaluated. ReturnsnullwhenworkingDiris null or nokarate-boot.jsis 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).
-