From 9ffc2874daaf8dee56ddb4ccd90e6f3b7e099a8b Mon Sep 17 00:00:00 2001 From: Roch Bertucat Date: Fri, 18 Dec 2020 11:22:14 +0100 Subject: [PATCH] Add a way to stop if fail step and improve report accordingly --- .../bimtester/features/environment.py | 2 +- src/ifcbimtester/bimtester/reports.py | 27 ++++++++++++++----- 2 files changed, 22 insertions(+), 7 deletions(-) diff --git a/src/ifcbimtester/bimtester/features/environment.py b/src/ifcbimtester/bimtester/features/environment.py index 167171f90a..b1bd18adfc 100644 --- a/src/ifcbimtester/bimtester/features/environment.py +++ b/src/ifcbimtester/bimtester/features/environment.py @@ -3,5 +3,5 @@ from behave.model import Scenario def before_all(context): userdata = context.config.userdata - continue_after_failed = True + continue_after_failed = userdata.getbool("runner.continue_after_failed_step", True) Scenario.continue_after_failed_step = continue_after_failed diff --git a/src/ifcbimtester/bimtester/reports.py b/src/ifcbimtester/bimtester/reports.py index bb82ea3b71..0aa7edd400 100644 --- a/src/ifcbimtester/bimtester/reports.py +++ b/src/ifcbimtester/bimtester/reports.py @@ -4,8 +4,8 @@ import os import pystache -def generate_report(adir="."): - print("# Generating HTML reports now.") +def generate_report(adir=".", use_report_folder=True, report_file_name="", html_template_file_path=""): + #print("# Generating HTML reports now.") # get html template html_template_file = os.path.join( @@ -13,11 +13,20 @@ def generate_report(adir="."): "features/template.html" ) + if html_template_file_path: + html_template_file = os.path.join(html_template_file_path, "template.html") + # get report file - report_dir = os.path.join(adir, "report") + report_dir = adir + if use_report_folder: + report_dir = os.path.join(adir, "report") if not os.path.exists(report_dir): return print("No report directory was found.") - report_path = os.path.join(report_dir, "report.json") + + if report_file_name: + report_path = os.path.join(report_dir, report_file_name) + else: + report_path = os.path.join(report_dir, "report.json") # print(report_path) if not os.path.exists(report_path): return print("No report data was found.") @@ -58,7 +67,12 @@ def generate_report(adir="."): if "match" in step and "arguments" in step["match"]: for a in step["match"]["arguments"]: name = name.replace(a["value"], "" + a["value"] + "") - if "result" not in step or step["result"]["status"] == "undefined": + if "result" not in step: + step["result"] = {} + step["result"]["status"] = "skipped" + step["result"]["duration"] = 0 + step["result"]["error_message"] = "This requirement has been skipped due to a previous failing step." + elif step["result"]["status"] == "undefined": step["result"] = {} step["result"]["status"] = "undefined" step["result"]["duration"] = 0 @@ -68,7 +82,8 @@ def generate_report(adir="."): "name": name, "time": round(step["result"]["duration"], 2), "is_success": step["result"]["status"] == "passed", - "is_unspecified": "result" not in step or step["result"]["status"] == "undefined", + "is_unspecified": step["result"]["status"] == "undefined", + "is_skipped": step["result"]["status"] == "skipped", "error_message": None if step["result"]["status"] == "passed" else step["result"]["error_message"],