Skip to content

Commit f989517

Browse files
authored
Merge pull request #479 from radish-bdd/adding-start-and-end-time-in-cucumber-json
Adding the start time and end time of the step for cucumber json
2 parents 112e3d8 + de3b1b9 commit f989517

File tree

4 files changed

+20
-2
lines changed

4 files changed

+20
-2
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ This project adheres to [Semantic Versioning](http://semver.org/).
99
- utcnow deprecation
1010

1111
### Changes
12+
- Adding start and end time in cucumber json
1213
- Drop Python 3.6 and Python 3.7
1314
- Drop the `--profile` option, please use `--user-data`
1415
- Change default marker from unix timestamp to UUIDv4

radish/extensions/cucumber_json_writer.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,12 @@ def generate_ccjson(self, features, marker):
8989
"keyword": step.sentence.split()[0],
9090
"name": step.sentence,
9191
"line": step.line,
92-
"result": {"status": step.state, "duration": duration},
92+
"result": {
93+
"status": step.state,
94+
"duration": duration,
95+
"starttime": str(step.starttime if step.starttime else 0.0),
96+
"endtime": str(step.endtime if step.endtime else 0.0),
97+
},
9398
}
9499
if step.state is Step.State.FAILED:
95100
step_json["result"]["error_message"] = step.failure.reason

tests/output/cucumber-json.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
"name": "Given I have the number 1",
1616
"result": {
1717
"duration": 343000.0,
18+
"endtime": "2024-11-20 08:37:18.133736+00:00",
19+
"starttime": "2024-11-20 08:37:17.255751+00:00",
1820
"status": "passed"
1921
}
2022
},
@@ -24,6 +26,8 @@
2426
"name": "And I have the number 2",
2527
"result": {
2628
"duration": 156000.0,
29+
"endtime": "2024-11-20 08:37:18.133736+00:00",
30+
"starttime": "2024-11-20 08:37:17.255751+00:00",
2731
"status": "passed"
2832
}
2933
},
@@ -33,6 +37,8 @@
3337
"name": "When I add them up with failure",
3438
"result": {
3539
"duration": 850000.0,
40+
"endtime": "2024-11-20 08:37:18.133736+00:00",
41+
"starttime": "2024-11-20 08:37:17.255751+00:00",
3642
"error_message": "Unable to add numbers: [1, 2]",
3743
"status": "failed"
3844
}
@@ -43,6 +49,8 @@
4349
"name": "Then I expect the sum to be 42",
4450
"result": {
4551
"duration": 73000.0,
52+
"endtime": "2024-11-20 08:37:18.133736+00:00",
53+
"starttime": "2024-11-20 08:37:17.255751+00:00",
4654
"status": "skipped"
4755
}
4856
}
@@ -68,6 +76,8 @@
6876
"name": "When generate cucumber report",
6977
"result": {
7078
"duration": 0.0,
79+
"endtime": "2024-11-20 08:37:18.133736+00:00",
80+
"starttime": "2024-11-20 08:37:17.255751+00:00",
7181
"status": "skipped"
7282
}
7383
},
@@ -77,6 +87,8 @@
7787
"name": "Then genreated cucumber json equals to \"cucumber-json.json\"",
7888
"result": {
7989
"duration": 0.0,
90+
"endtime": "2024-11-20 08:37:18.133736+00:00",
91+
"starttime": "2024-11-20 08:37:17.255751+00:00",
8092
"status": "pending"
8193
}
8294
}

tests/radish/steps.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ def generate_cucumber_report(step):
162162
@then("genreated cucumber json equals to {expected_json_file:QuotedString}")
163163
def proper_cucumber_json_is_generated(step, expected_json_file):
164164
def remove_changing(d):
165-
return {k: v for k, v in d.items() if k not in ["duration", "uri"]}
165+
return {k: v for k, v in d.items() if k not in ["duration", "uri", "endtime", "starttime"]}
166166

167167
with open(world.config.cucumber_json, "r") as f_cucumber_json:
168168
cucumber_json = json.load(f_cucumber_json, object_hook=remove_changing)

0 commit comments

Comments
 (0)