Class JsonLinesReportListener

java.lang.Object
io.karatelabs.output.JsonLinesReportListener
All Implemented Interfaces:
ResultListener

public class JsonLinesReportListener extends Object implements ResultListener
A ResultListener that streams test results to a JSON Lines (.jsonl) file.

This listener writes feature results as they complete during test execution, enabling:

  • Memory efficiency - results written to disk immediately, not held in memory
  • Streaming - can tail the file during execution for live progress
  • Easy aggregation - multiple JSON Lines files can be concatenated

JSON Lines format:

 {"t":"suite","time":"2025-12-16T10:30:00Z","threads":5,"env":"dev","version":"..."}
 {"t":"feature","path":"features/users.feature","name":"User Management","scenarios":[...],"passed":true,"ms":1234}
 {"t":"suite_end","featuresPassed":10,"featuresFailed":2,"scenariosPassed":42,"scenariosFailed":3,"ms":12345}
 

At suite end, this listener generates HTML reports from the accumulated JSON Lines data.

  • Constructor Details

    • JsonLinesReportListener

      public JsonLinesReportListener(Path outputDir, String env)
      Create a new JSON Lines report listener.
      Parameters:
      outputDir - the directory to write reports
      env - the karate environment (may be null)
  • Method Details

    • onSuiteStart

      public void onSuiteStart(Suite suite)
      Description copied from interface: ResultListener
      Called when the suite starts execution.
      Specified by:
      onSuiteStart in interface ResultListener
      Parameters:
      suite - the suite about to run
    • onFeatureEnd

      public void onFeatureEnd(FeatureResult result)
      Description copied from interface: ResultListener
      Called when a feature completes execution.
      Specified by:
      onFeatureEnd in interface ResultListener
      Parameters:
      result - the feature result
    • onSuiteEnd

      public void onSuiteEnd(SuiteResult result)
      Description copied from interface: ResultListener
      Called when the suite completes execution.
      Specified by:
      onSuiteEnd in interface ResultListener
      Parameters:
      result - the final suite result
    • getJsonlPath

      public Path getJsonlPath()
      Get the path to the JSON Lines file.