Skip to content

Commit

Permalink
Adding failure reports to failed test case description #44
Browse files Browse the repository at this point in the history
  • Loading branch information
Vojtech Burian committed Jun 15, 2015
1 parent 2c6f224 commit 7ef7022
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
14 changes: 10 additions & 4 deletions shishito/reporting/reporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,15 @@ def get_xunit_test_cases(self, timestamp):
root = tree.getroot()
for child in root:
if child.tag == 'testcase':
case['cases'].append({
'name': child.get('name'),
'result': 'failure' if child.findall('failure') else 'success',
})
failure = child.find('failure')
entry = {'name': child.get('name')}
# ET Element object returns bool False, so condition needs to check against None value
if failure is not None:
entry['result'] = 'failure'
entry['failure_message'] = failure.text
else:
entry['result'] = 'success'
entry['failure_message'] = None
case['cases'].append(entry)
test_cases.append(case)
return test_cases
6 changes: 5 additions & 1 deletion shishito/services/testrail_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,11 @@ def add_test_results(self, test_runs):
tr_test_id = tr_tests.get(xunit_test['name'])
result_id = {'success': 1, 'failure': 5}.get(xunit_test['result'])
if tr_test_id and result_id:
test_results.append({'test_id': tr_test_id, 'status_id': result_id})
# Add result content into the payload list
result = {'test_id': tr_test_id, 'status_id': result_id}
if result_id == 5:
result['comment'] = xunit_test['failure_message']
test_results.append(result)

response = self.tr_post('add_results/{}'.format(run_id), {'results': test_results})
if response.status_code != requests.codes.ok:
Expand Down

0 comments on commit 7ef7022

Please sign in to comment.