import unittest
#some def
class BaseTest(unittest.TestCase):
#some def
def setUp(self):
#初始化、环境构建
def tearDown(self):
#环境还原
class TestOne(BaseTest):
#some def
def test_one(self):
#必须以test_开头
class TestTwo(BaseTest):
#some def
def test_two(self):
#必须以test_开头
main():
stream = log.init(LOG_FILE_PATH,True)
f = open(LOG_FILE_PATH, 'w')
test_suite = unittest.TestSuite()
test_loader = unittest.TestLoader()
test_suite.addTests(test_loader.loadTestsFromTestCase(TestOne))
test_suite.addTests(test_loader.loadTestsFromTestCase(TestTwo))
# 将unittest自带的log与自设定log写在一起
unittest.TextTestRunner(stream, verbosity=2).run(test_suite)
f.close
if __name__ == '__main__':
main()
python unitTest使用框架
最新推荐文章于 2024-09-04 10:31:20 发布