Skip to content

Commit

Permalink
BUGZID: 90176 Extract method
Browse files Browse the repository at this point in the history
  • Loading branch information
nbelliot committed Apr 29, 2020
1 parent a716cdf commit 846e567
Showing 1 changed file with 33 additions and 26 deletions.
59 changes: 33 additions & 26 deletions src/main/resources/scripts/generate_xml.py
Original file line number Diff line number Diff line change
Expand Up @@ -473,19 +473,11 @@ def write_testcase_jUnit(self, tc, unit_name, func_name):
exp_pass += summary.control_flow_total - summary.control_flow_fail
exp_total += summary.control_flow_total + summary.signals + summary.unexpected_exceptions

exec_rpt_name = hashlib.md5("execution_results." + classname + "." + unit_subp + "." + tc_name).hexdigest()

self.api.report(
testcases=[tc],
single_testcase=True,
report_type="Demo",
formats=["TEXT"],
output_file=exec_rpt_name,
sections=[ "TESTCASE_SECTIONS"],
testcase_sections=["EXECUTION_RESULTS"])

result = open(exec_rpt_name,"r").read()
os.remove(exec_rpt_name)
result = self.__get_testcase_execution_results(
tc,
classname,
unit_subp,
tc_name)

# Failure takes priority
if not tc.passed:
Expand Down Expand Up @@ -535,23 +527,16 @@ def write_testcase_xUnit(self, tc, unit_name, func_name):
if tc.passed:
msg = "PASS"
else:
exec_rpt_name = hashlib.md5("execution_results." + classname + "." + unit_subp + "." + tc_name).hexdigest()

self.api.report(
testcases=[tc],
single_testcase=True,
report_type="Demo",
formats=["TEXT"],
output_file=exec_rpt_name,
sections=[ "TESTCASE_SECTIONS"],
testcase_sections=["EXECUTION_RESULTS"])

result = open(exec_rpt_name,"r").read()
result = self.__get_testcase_execution_results(
tc,
unit_name,
func_name,
tc_name)

result = cgi.escape(result)
result = result.replace("\"","")
result = result.replace("\n","
")
msg = "FAIL {} / {} Execution Report:\n {}".format(exp_pass, exp_total, result)
os.remove(exec_rpt_name)

self.fh.write(' <message>%s</message>\n' % msg)
self.fh.write(' </test>\n')
Expand Down Expand Up @@ -720,6 +705,28 @@ def was_test_case_skipped(self, tc, searchName):
traceback.print_exc()
sys.exit()

def __get_testcase_execution_results(self, tc, classname, unit_subp, tc_name):
report_name = hashlib.md5('.'.join(["execution_results",
classname,
unit_subp,
tc_name])).hexdigest()

self.api.report(
testcases=[tc],
single_testcase=True,
report_type="Demo",
formats=["TEXT"],
output_file=report_name,
sections=[ "TESTCASE_SECTIONS"],
testcase_sections=["EXECUTION_RESULTS"])

with open(report_name,"r") as f:
out = f.read()

os.remove(report_name)

return out

def __print_test_case_was_skipped(self, searchName, passed):
if self.verbose:
print("skipping ", self.hashCode, searchName, passed)

0 comments on commit 846e567

Please sign in to comment.