Package io.karatelabs.output
Class CucumberJsonWriter
java.lang.Object
io.karatelabs.output.CucumberJsonWriter
Generates Cucumber JSON reports compatible with third-party tools (Allure, ReportPortal, etc.).
Output follows the standard Cucumber JSON schema:
[
{
"id": "feature-id",
"uri": "path/to/feature.feature",
"name": "Feature Name",
"keyword": "Feature",
"elements": [
{
"id": "feature-id;scenario-id",
"name": "Scenario Name",
"keyword": "Scenario",
"type": "scenario",
"steps": [
{
"keyword": "Given ",
"name": "step text",
"result": { "status": "passed", "duration": 12345678 }
}
]
}
]
}
]
-
Method Summary
Modifier and TypeMethodDescriptionstatic StringfeatureToJson(FeatureResult result) Convert a single feature result to Cucumber JSON string.static StringfileNameFor(FeatureResult result) File name this feature's output is written under.static StringserializeFeature(FeatureResult result) Serialize a feature result to its JSON text.static voidwriteFeature(FeatureResult result, Path outputDir) static voidwriteSerialized(String fileName, String content, Path outputDir) Write pre-serialized content.
-
Method Details
-
serializeFeature
Serialize a feature result to its JSON text.Separated from the file write so a listener can do this synchronously, while the result is still whole. The suite releases nested
karate.call()trees once a feature's listeners have returned, and this output flattens called features' steps into its own — so serializing on a background thread would silently drop them. -
fileNameFor
File name this feature's output is written under. -
writeSerialized
Write pre-serialized content. Safe after the source result has been released. -
writeFeature
-
featureToJson
Convert a single feature result to Cucumber JSON string.Returns a JSON array containing a single feature object.
- Parameters:
result- the feature result- Returns:
- JSON string
-