Package io.karatelabs.core
Class KaratePom
java.lang.Object
io.karatelabs.core.KaratePom
Represents Karate project configuration loaded from karate-pom.json.
This is distinct from karate-config.js (runtime bootstrap) and the configure keyword (runtime settings). The pom file defines how to run tests: paths, tags, threads, output settings.
Example karate-pom.json:
{
"paths": ["src/test/features/"],
"tags": ["@smoke", "~@slow"],
"env": "dev",
"threads": 5,
"scenarioName": "Login happy path",
"configDir": "src/test/resources",
"workingDir": "/home/user/project",
"dryRun": false,
"clean": false,
"output": {
"dir": "target/karate-reports",
"html": true,
"junitXml": false,
"cucumberJson": false,
"jsonLines": false
},
"logging": {
"report": "debug",
"console": "info"
},
"listeners": ["com.example.MyListener"],
"listenerFactories": ["com.example.MyListenerFactory"]
}
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classLogging configuration nested object.static classOutput configuration nested object. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionapplyTo(Runner.Builder builder) Apply this configuration to a Runner.Builder.getEnv()getPaths()getTags()intbooleanisClean()booleanisDryRun()static KaratePomLoad configuration from a JSON file.static KaratePomLoad configuration from a JSON file.static KaratePomParse configuration from a JSON string.voidsetClean(boolean clean) voidsetConfigDir(String configDir) voidsetDryRun(boolean dryRun) voidvoidsetListenerFactories(List<String> listenerFactories) voidsetListeners(List<String> listeners) voidsetLogging(KaratePom.LoggingPom logging) voidsetOutput(KaratePom.OutputPom output) voidvoidsetScenarioName(String scenarioName) voidvoidsetThreads(int threads) voidsetWorkingDir(String workingDir)
-
Constructor Details
-
KaratePom
public KaratePom()
-
-
Method Details
-
load
Load configuration from a JSON file.- Parameters:
configPath- path to the JSON config file- Returns:
- parsed KaratePom
- Throws:
RuntimeException- if file cannot be read or parsed
-
load
Load configuration from a JSON file.- Parameters:
configPath- path to the JSON config file- Returns:
- parsed KaratePom
- Throws:
RuntimeException- if file cannot be read or parsed
-
parse
Parse configuration from a JSON string.- Parameters:
json- JSON string- Returns:
- parsed KaratePom
- Throws:
RuntimeException- if JSON is invalid
-
applyTo
Apply this configuration to a Runner.Builder. CLI options should override config file values, so call this before applying CLI options.- Parameters:
builder- the Runner.Builder to configure- Returns:
- the same builder for chaining
-
getPaths
-
setPaths
-
getTags
-
setTags
-
getEnv
-
setEnv
-
getThreads
public int getThreads() -
setThreads
public void setThreads(int threads) -
getScenarioName
-
setScenarioName
-
getConfigDir
-
setConfigDir
-
isDryRun
public boolean isDryRun() -
setDryRun
public void setDryRun(boolean dryRun) -
isClean
public boolean isClean() -
setClean
public void setClean(boolean clean) -
getWorkingDir
-
setWorkingDir
-
getOutput
-
setOutput
-
getLogging
-
setLogging
-
getListeners
-
setListeners
-
getListenerFactories
-
setListenerFactories
-