The Idea is really good, but there are many cases that are not covered and makes this script not easy to use.
Not all Scenario have a tag
The status of a step could be undefined
Background scenarios are also important, since they are executed before each
In my case, the cucumber's xml reports had 1 failed scenario but the xml file provide by cucumber_json_to_junit.py has no failure.
I can't provide a fix for now, but generally it'S good to cache exceptions when accessing data structure like dict or list. Or even check for existence before accessing the data.
This is just to show how to add a 'basic' fix for one of he points mentioned above
diff --git a/cucumber_json_to_junit_xml/cucumber_json_to_junit.py b/cucumber_json_to_junit_xml/cucumber_json_to_junit.py
index 3fe95e5..5e039c7 100644
--- a/cucumber_json_to_junit_xml/cucumber_json_to_junit.py
+++ b/cucumber_json_to_junit_xml/cucumber_json_to_junit.py
@@ -47,7 +47,7 @@ def main():
scenario_status = "passed"
scenario_time = 0.0
- if scenario["type"] != "background":
+ if scenario["type"] != "background" and "tags" in scenario:
for tag in scenario["tags"]:
steps_blob += tag["name"] + " "
steps_blob += "\n"
@@ -59,7 +59,7 @@ def main():
status = sanitize(results["status"])
keyword = sanitize(step["keyword"])
- if status != "skipped":
+ if status not in ["skipped", "undefined"]:
scenario_time += float(results["duration"]) / 1000000000
num_dots = 83 - len(keyword) - len(description) - len(status)
The Idea is really good, but there are many cases that are not covered and makes this script not easy to use.
In my case, the cucumber's xml reports had 1 failed scenario but the xml file provide by cucumber_json_to_junit.py has no failure.
I can't provide a fix for now, but generally it'S good to cache exceptions when accessing data structure like dict or list. Or even check for existence before accessing the data.
This is just to show how to add a 'basic' fix for one of he points mentioned above