""" Collect result and associated testcases (TestRail) of an execution """
outcome = yield
rep = outcome.get_result()
defectids = None
if item.get_closest_marker(TESTRAIL_DEFECTS_PREFIX):
defectids = item.get_closest_marker(TESTRAIL_DEFECTS_PREFIX).kwargs.get('defect_ids')
if item.get_closest_marker(TESTRAIL_PREFIX):
testcaseids = item.get_closest_marker(TESTRAIL_PREFIX).kwargs.get('ids')
if rep.when == 'call' and testcaseids:
if defectids != None:
self.add_result(
clean_test_ids(testcaseids),
get_test_outcome(outcome.get_result().outcome),
comment=rep.longrepr,
duration=rep.duration,
defects=str(clean_test_defects(defectids)).replace('[', '').replace(']', '').replace("'", '')
)
else:
self.add_result(
clean_test_ids(testcaseids),
get_test_outcome(outcome.get_result().outcome),
comment=rep.longrepr,
duration=rep.duration
)
We add result only if rep.when == 'call', that mean that if we will fail test on setup or teardown, we don't get message that test failed. If test failed at setup - we don't send any message. If test failed at teardown - we send message that test passed.
We add result only if
rep.when == 'call'
, that mean that if we will fail test on setup or teardown, we don't get message that test failed. If test failed at setup - we don't send any message. If test failed at teardown - we send message that test passed.