【发布时间】:2015-04-06 00:38:41
【问题描述】:
我有一个用 Selenium Webdriver/Python 2.7 编写的测试套件,其中包含几个测试用例。一些测试用例非常关键,如果它们失败了,整个测试就失败了,之后就不需要运行测试用例了。
class TestSuite1(unittest.TestCase)
def setUp(self):
pass
def test1(self):
return True
def test2(self):
return false
def test3(self):
return True
# This is a critical test
def test4(self):
return false
def test5(self):
return True
def tearDown(self):
pass
所以,我想在 test4 失败时停止整个测试运行(当 test2 失败时应该继续测试运行),因为它很关键。我知道我们可以使用装饰器,但我正在寻找一种更有效的方法,因为我的测试运行中有大约 20 个关键测试,并且对所有测试用例使用 20 个标志似乎并不高效。
【问题讨论】:
标签: python unit-testing selenium selenium-webdriver python-unittest