Skip to content

Commit

Permalink
QE-10881 Fix output when feature is empty (#315)
Browse files Browse the repository at this point in the history
There is a bug introduced recently that causes cucu to not be able to
handle empty feature files
  • Loading branch information
ddl-xin authored Mar 6, 2023
1 parent 6bebd18 commit 446f567
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion features/cli/report_basics.feature
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ Feature: Report basics
"""
Feature: nothing to see here
"""
When I run the command "cucu run {CUCU_RESULTS_DIR}/empty_features --results {CUCU_RESULTS_DIR}/empty_features_results --generate-report --report {CUCU_RESULTS_DIR}/empty_features_report" and save stdout to "STDOUT", stderr to "STDERR" and expect exit code "1"
When I run the command "cucu run {CUCU_RESULTS_DIR}/empty_features --results {CUCU_RESULTS_DIR}/empty_features_results --generate-report --report {CUCU_RESULTS_DIR}/empty_features_report" and save stdout to "STDOUT", stderr to "STDERR" and expect exit code "0"
And I start a webserver at directory "{CUCU_RESULTS_DIR}/empty_features_report/" and save the port to the variable "PORT"
And I open a browser at the url "http://{HOST_ADDRESS}:{PORT}/index.html"
Then I should see the text "No data available in table"
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "cucu"
version = "0.119.0"
version = "0.120.0"
license = "MIT"
description = ""
authors = ["Rodney Gomes <[email protected]>"]
Expand Down
3 changes: 3 additions & 0 deletions src/cucu/formatter/json.py
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,9 @@ def write_json_footer(self):
self.stream.write("\n]\n")

def write_json_feature(self, feature_data):
if "elements" not in feature_data:
return

filtered_scenarios = [
x
for x in feature_data["elements"]
Expand Down
4 changes: 1 addition & 3 deletions src/cucu/formatter/junit.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,9 +210,7 @@ def attributes(self, tag):
scenarios = filtered_scenarios

if len(scenarios) == 0:
# we had a suite of just skipped results and should remove the
# results all together
os.remove(output_filepath)
# we had a suite of just skipped results
return

# calculate with the latest data
Expand Down

0 comments on commit 446f567

Please sign in to comment.