1.默认测试方法都是以test开头 ,按照顺序执行
如何控制case按照自定义的顺序执行
#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)
或者
if __name__=="__main__":
suite=unittest.TestSuite()
tests=[TestCase01('test_02'),TestCase01('test_03')]
suite.addTests(tests)
runner=unittest.TextTestRunner()
runner.run(suite)