标签:执行 tar __name__ 默认 logout Suite raft draft testcase
import unittest
class Study(unittest.TestCase):
# def setUp(self):
# print(‘start‘)
# def tearDown(self):
# print(‘end‘)
def test_login(self):
print(‘login‘)
def test_draft(self):
print(‘draft‘)
def test_logout(self):
print(‘logout‘)
def xixi(self): #非test开头,不执行
print(‘hehe‘)
if __name__=="__main__":
#unittest.main() #默认执行属性按0-9,A-Z,a-z #使用TestSuite则将此句屏蔽掉
ss=unittest.TestSuite()
ss.addTest(Study(‘test_login‘))
ss.addTest(Study(‘test_draft‘))
ss.addTest(Study(‘test_logout‘))
rr=unittest.TextTestRunner()
rr.run(ss)
unittest执行顺序,使用unittest.main()按照test开头,由0-9,A-Z,a-z的顺序执行; 可使用TestSuite类的addTest方法改变执行顺序;
标签:执行 tar __name__ 默认 logout Suite raft draft testcase
原文地址:https://www.cnblogs.com/canglongdao/p/11968061.html