I want it to carry on with the rest of the tests, but I also want some information about these failures. What exceptions were raised and where they were raised. This is how I'm doing it:
import sys
import traceback
…
try:
myTestCase.executeTestSteps()
except:
# handle and log exceptions
exctype, value, trace = sys.exc_info()[:3]
extracted_tb = traceback.extract_tb(trace)
printAndLog("**********************');
printAndLog(str(exctype) + ':' + str(value))
for tb_line in extracted_tb:
printAndLog(str(tb_line[0]) + 'line ' + str(tb_line[1]) + ' in ' + str(tb_line[2]) + ' (' + str(tb_line[3]) + ')')
printAndLog("**********************');
del trace
( Where myTestCase is the thing I want to run and printAndLog (you'll have to roll your own) sends to the console and to a log file)
No comments:
Post a Comment