import unittest
class MyTest1(unittest.TestCase):
def test1(self):
print('test - 1')
def test2(self):
print('test - 2')
class MyTest2(unittest.TestCase):
def test3(self):
print('test - 3')
def test4(self):
print('test - 4')
if __name__ == '__main__':
# unittest.main()
# 实例化测试套件
suite = unittest.TestSuite()
# 实例化加载器
loader = unittest.TestLoader()
# 实例化运行器
runner = unittest.TextTestRunner()
# 1- 通过测试类进行加载
suite.addTest(loader.loadTestsFromTestCase(MyTest1))
# 通过运行器运行测试套件
runner.run(suite)
为什么加载了MyTest1,执行结果却是MyTest1和MyTest2都跑了,哪里写的不对吗