执行代码,如果测试失败,py.test
问题描述:
我正在使用Appium和py.test在Android上进行UI测试自动化。我希望能够在测试失败后使用adb保存错误报告。执行代码,如果测试失败,py.test
有没有方法可以告诉我的测试代码中的测试是否失败,这样我就可以在拆卸后运行保存错误报告了?
最初,我只是想在每次测试后保存错误报告,但是每次测试增加45秒会有点过度。
答
您可以在conftest.py
这样实现pytest_runtest_logreport
钩:
def pytest_runtest_logreport(report):
if report.when == 'call' and report.failed:
# save bug report
欲了解更多信息,请参阅Woking with plugins and conftest files。
你是否考虑过启动一个子进程来监控python中的adb日志?如果这就是你想要的 – 2014-10-08 15:17:28