标签:选择性 str Suite ase equal runner bsp ddt erb
import unittest
class Mytest(unittest.TestCase):
def setUp(self):
print(‘start...‘)
def test_001(self):
self.assertEqual(‘a‘,‘b‘)
print(‘001‘)
def test_002(self):
print(‘002‘)
def tearDown(self):
print(‘over...‘)
class Mytest2(unittest.TestCase):
def setUp(self):
print(‘start...‘)
def test_001(self):
print(‘001‘)
def test_002(self):
print(‘002‘)
def tearDown(self):
print(‘over...‘)
if __name__ == ‘__main__‘:
unittest.main() #全部执行
mysuit = unittest.TestSuite() #选择性执行
mysuit.addTest(Mytest2(‘test_001‘))
mysuit.addTest(Mytest2(‘test_002‘))
unittest.TextTestRunner(verbosity=2).run(mysuit)
Setup,tearDown 为固定用法,类方法必须以test为开头命名
标签:选择性 str Suite ase equal runner bsp ddt erb
原文地址:https://www.cnblogs.com/zhang-dan/p/9977628.html