Package io.karatelabs.core
Class JsonLinesEventWriter
java.lang.Object
io.karatelabs.core.JsonLinesEventWriter
- All Implemented Interfaces:
RunListener,Closeable,AutoCloseable
A
RunListener that streams events to a JSON Lines (.jsonl) file.
This writer outputs events in the standard envelope format:
{"type":"SUITE_ENTER","timeStamp":1703500000000,"threadId":null,"data":{...}}
{"type":"FEATURE_ENTER","timeStamp":1703500000010,"threadId":"worker-1","data":{...}}
{"type":"SCENARIO_ENTER","timeStamp":1703500000020,"threadId":"worker-1","data":{...}}
{"type":"SCENARIO_EXIT","timeStamp":1703500000100,"threadId":"worker-1","data":{...}}
{"type":"FEATURE_EXIT","timeStamp":1703500000200,"threadId":"worker-1","data":{...}}
{"type":"SUITE_EXIT","timeStamp":1703500010000,"threadId":null,"data":{...}}
Use cases:
- Real-time test dashboards - stream lightweight events as tests run
- CI/CD integration - parse events for build status, notifications
- Report aggregation - combine JSONL from multiple runs/machines
- IDE integration - SCENARIO_ENTER/EXIT events for test runners
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionJsonLinesEventWriter(Path outputDir, String env, int threadCount) Create a new JSON Lines event writer. -
Method Summary
-
Field Details
-
DEFAULT_FILENAME
- See Also:
-
SCHEMA_VERSION
- See Also:
-
-
Constructor Details
-
JsonLinesEventWriter
Create a new JSON Lines event writer.- Parameters:
outputDir- the directory to write the fileenv- the karate environment (may be null)threadCount- the number of parallel threads
-
-
Method Details
-
init
Initialize the writer. Must be called before events are fired.- Throws:
IOException
-
onEvent
Description copied from interface:RunListenerCalled for all runtime events.- Specified by:
onEventin interfaceRunListener- Parameters:
event- the event containing type, runtime objects, and results- Returns:
- true to continue execution, false to skip (only meaningful for *_ENTER events)
-
close
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Throws:
IOException
-
getJsonlPath
Get the path to the JSON Lines file.
-