Permalink
Browse files

Merge XUnit information into structured data (json) output.

XUnit information contains information about whether a test actually passed or failed - as well well as more detailed log of failure - merging this into the structured JSON blob allows one to easily combine these two sources of data - and say build a test report HTML page.
  • Loading branch information...
jmchilton committed Dec 7, 2014
1 parent a95ebfc commit 82e8b1f17eae526aeb341cb4fffb8d09d73bb419
Showing with 25 additions and 0 deletions.
  1. +25 −0 planemo/galaxy_test.py
@@ -21,6 +21,13 @@ def __init__(self, output_json_path, output_xml_path):
structured_data_tests = {}
self.structured_data = structured_data
self.structured_data_tests = structured_data_tests

structured_data_by_id = {}
for test in self.structured_data_tests:
structured_data_by_id[test["id"]] = test["data"]
self.structured_data_by_id = structured_data_by_id
print structured_data_by_id

self.xunit_tree = ET.parse(output_xml_path)
self.__merge_xunit()
try:
@@ -49,6 +56,24 @@ def __merge_xunit(self):
self.num_tests = num_tests
self.num_problems = num_skips + num_errors + num_failures

for testcase_el in self.xunit_testcase_elements:
id = testcase_el.get("name")
test_data = self.structured_data_by_id.get(id)
if not test_data:
continue
problem_el = None
for problem_type in ["skip", "failure", "error"]:
problem_el = testcase_el.find(problem_type)
if problem_el is not None:
break
if problem_el is not None:
status = problem_el.tag
test_data["problem_type"] = problem_el.attrib["type"]
test_data["problem_log"] = problem_el.text
else:
status = "success"
test_data["status"] = status

@property
def all_tests_passed(self):
return self.num_problems == 0

0 comments on commit 82e8b1f

Please sign in to comment.