- # 在一个脚本里面,用测试套件运行多个接口
- import unittest
-
- # 定义类
- class lei (unittest.TestCase):
- # 初始化
- def setUp(self):
- print('setUp')
-
- # 登录接口
- def test_login(self):
- print('login')
- # 注册接口
- def test_register(self):
- print('register')
- # 验证邮箱是否重复接口
- def test_email(self):
- print('email')
-
- def tearDown(self):
- print('tearDown')
-
- if __name__ == '__main__':
- # 声明运行脚本的路径
- path='./'
- # 声明测试用例集
- suite=unittest.defaultTestLoader.discover(path,'1.py')
- # 声明测试运行对象
- runner=unittest.TextTestRunner()
- # 执行测试用例集
- runner.run(suite)