Skip to content

Commit

Permalink
Merge XUnit information into structured data (json) output.
Browse files Browse the repository at this point in the history
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 8, 2014
1 parent a95ebfc commit 82e8b1f
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions planemo/galaxy_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 82e8b1f

Please sign in to comment.