正常的unittest框架,setUp和tearDown每一个用例开始都会运行一次,比如打开浏览器,每次浏览器都会打开关闭后再运行第二个测试用例,现修改为一下情况即可解决这个问题
未修改前的框架代码:
class TestDemo(unittest.TestCase):
def setUp(self):
def tearDown(self):
def test_1(self):
print("test_1")
修改:在setUp和tearDown前加上@classmethod
class TestDemo(unittest.TestCase):
@classmethod
def setUpClass(cls):
@classmethod
def tearDownClass(cls):
def ttest_1(self):