1.默认测试方法都是以test开头 ,按照顺序执行
如何控制case按照自定义的顺序执行,可以使用 TestSuite , 将测试case按自己要的顺序添加addTest到其中
#coding=utf-8 import requests import unittest class TestCase01(unittest.TestCase): def setUp(self): pass def tearDown(self): pass @classmethod def setUpClass(cls): pass @classmethod def tearDownClass(cls): pass def test_01(self): print("case01") def test_02(self): print("case02") def test_03(self): print("case03") if __name__=="__main__": suite=unittest.TestSuite() suite.addTest(TestCase01('test_02')) suite.addTest(TestCase01('test_03')) runner=unittest.TextTestRunner() runner.run(suite)