Python 单元测试模块,通用断言记录器
Python unittest module, general assertion logger
我正在使用 https://github.com/2gis/winphonedriver
框架
为我的 Windows Phone 8 应用程序编写 selenium 测试
我正在使用 unittest
模块,作为 'base' 测试框架
我想在至少一个断言失败时截取设备屏幕。
问题:
unittest
模块是否有一些特定的 function/method 在断言失败时调用?
目前我只找到一种解决方案http://www.piware.de/2012/10/python-unittest-show-log-on-test-failure/
我刚刚 post 来自上面 link 的代码
class MyTestCase(unittest.TestCase):
def run(self, result=None):
'''Show log output on failed tests'''
if result:
orig_err_fail = result.errors + result.failures
super().run(result)
if result and result.errors + result.failures > orig_err_fail:
print ("assertion failed")
我正在使用 https://github.com/2gis/winphonedriver
框架
我正在使用 unittest
模块,作为 'base' 测试框架
我想在至少一个断言失败时截取设备屏幕。
问题:
unittest
模块是否有一些特定的 function/method 在断言失败时调用?
目前我只找到一种解决方案http://www.piware.de/2012/10/python-unittest-show-log-on-test-failure/
我刚刚 post 来自上面 link 的代码
class MyTestCase(unittest.TestCase):
def run(self, result=None):
'''Show log output on failed tests'''
if result:
orig_err_fail = result.errors + result.failures
super().run(result)
if result and result.errors + result.failures > orig_err_fail:
print ("assertion failed")