Class KaratePom

java.lang.Object
io.karatelabs.core.KaratePom

public class KaratePom extends Object
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"]
 }
 
  • Constructor Details

    • KaratePom

      public KaratePom()
  • Method Details

    • load

      public static KaratePom load(String configPath)
      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

      public static KaratePom load(Path configPath)
      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

      public static KaratePom parse(String json)
      Parse configuration from a JSON string.
      Parameters:
      json - JSON string
      Returns:
      parsed KaratePom
      Throws:
      RuntimeException - if JSON is invalid
    • applyTo

      public Runner.Builder applyTo(Runner.Builder builder)
      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

      public List<String> getPaths()
    • setPaths

      public void setPaths(List<String> paths)
    • getTags

      public List<String> getTags()
    • setTags

      public void setTags(List<String> tags)
    • getEnv

      public String getEnv()
    • setEnv

      public void setEnv(String env)
    • getThreads

      public int getThreads()
    • setThreads

      public void setThreads(int threads)
    • getScenarioName

      public String getScenarioName()
    • setScenarioName

      public void setScenarioName(String scenarioName)
    • getConfigDir

      public String getConfigDir()
    • setConfigDir

      public void setConfigDir(String configDir)
    • isDryRun

      public boolean isDryRun()
    • setDryRun

      public void setDryRun(boolean dryRun)
    • isClean

      public boolean isClean()
    • setClean

      public void setClean(boolean clean)
    • getWorkingDir

      public String getWorkingDir()
    • setWorkingDir

      public void setWorkingDir(String workingDir)
    • getOutput

      public KaratePom.OutputPom getOutput()
    • setOutput

      public void setOutput(KaratePom.OutputPom output)
    • getLogging

      public KaratePom.LoggingPom getLogging()
    • setLogging

      public void setLogging(KaratePom.LoggingPom logging)
    • getListeners

      public List<String> getListeners()
    • setListeners

      public void setListeners(List<String> listeners)
    • getListenerFactories

      public List<String> getListenerFactories()
    • setListenerFactories

      public void setListenerFactories(List<String> listenerFactories)