全球排名前十网站,软件开发兼职网站,wordpress 知乎模版,如何用dw做网站地图unittest用例执行顺序
当在一个测试类或多个测试模块下#xff0c;用例数量较多时#xff0c;unittest在执行用例 #xff08;test_xxx#xff09;时#xff0c;并不是按从上到下的顺序执行#xff0c;有特定的顺序。
unittest框架默认根据ACSII码的顺序加载测试用例用例数量较多时unittest在执行用例 test_xxx时并不是按从上到下的顺序执行有特定的顺序。
unittest框架默认根据ACSII码的顺序加载测试用例数字与字母的顺序为 0~9A~Za~z。
对于类来说class TestAxx 会优先于class TestBxx被执行。对于方法来说test_aaa()方法会有优先于test_bbb()被执行。对于测试目录与测试文件来说unittest同样是按照这个规则来加载测试用例的。
方式一、通过测试用例的方法名称根据ACSII码的顺序加载测试用例
代码示例
# 测试用例的执行顺序
# 1通过测试用例的方法名称根据ACSII码的顺序加载测试用例
import unittest
class Test_case(unittest.TestCase):# 进行初始化和清理工作def setUp(self):print(我是setUp方法进行测试前的初始化工作)def tearDown(self) - None: # 表示该方法没有返回值print(我是tearDown方法执行测试后的清除工作)# 测试用例def test_bbb(self): # 判断是否在里面name [张飞,马怒,李四]self.assertIn(马怒,name)print(测试test_bbb执行结束)def test_ccc(self): # 判断42self.assertGreater(4,2)print(测试test_ccc执行结束)def test_aaa(self):a Trueself.assertTrue(a) # 判断是否为真print(测试test_aaa执行结束)if __name__ __main__:unittest.main()
查看执行结果 方式二、通过addtest()添加用例的顺序
代码示例
# 测试用例的执行顺序
# 2通过addtest()添加用例的顺序
import unittest
class Test_case(unittest.TestCase):# 进行初始化和清理工作def setUp(self):print(我是setUp方法进行测试前的初始化工作)def tearDown(self) - None: # 表示该方法没有返回值print(我是tearDown方法执行测试后的清除工作)def test_bbb(self): # 判断是否在里面name [张飞,马怒,李四]self.assertIn(马怒,name)print(测试test_bbb执行结束)def test_ccc(self): # 判断42self.assertGreater(4,2)print(测试test_ccc执行结束)def test_aaa(self):aTrueself.assertTrue(a) # 判断是否为真print(测试test_aaa执行结束)if __name__ __main__:suite unittest.TestSuite() # 测试套件实例suite.addTest(Test_case(test_bbb)) # 类名方法名称suite.addTest(Test_case(test_aaa))suite.addTest(Test_case(test_ccc))unittest.main(defaultTestsuite)
查看执行结果 最后感谢每一个认真阅读我文章的人礼尚往来总是要有的虽然不是什么很值钱的东西如果你用得到的话可以直接拿走 这些资料对于【软件测试】的朋友来说应该是最全面最完整的备战仓库这个仓库也陪伴上万个测试工程师们走过最艰难的路程希望也能帮助到你
文章转载自: http://www.morning.jbtlf.cn.gov.cn.jbtlf.cn http://www.morning.jnptt.cn.gov.cn.jnptt.cn http://www.morning.wcyr.cn.gov.cn.wcyr.cn http://www.morning.bqmsm.cn.gov.cn.bqmsm.cn http://www.morning.rwls.cn.gov.cn.rwls.cn http://www.morning.fnpmf.cn.gov.cn.fnpmf.cn http://www.morning.nbrdx.cn.gov.cn.nbrdx.cn http://www.morning.sknbb.cn.gov.cn.sknbb.cn http://www.morning.xhqr.cn.gov.cn.xhqr.cn http://www.morning.wcjgg.cn.gov.cn.wcjgg.cn http://www.morning.xrwbc.cn.gov.cn.xrwbc.cn http://www.morning.hlmkx.cn.gov.cn.hlmkx.cn http://www.morning.xlbtz.cn.gov.cn.xlbtz.cn http://www.morning.yqhdy.cn.gov.cn.yqhdy.cn http://www.morning.dbrpl.cn.gov.cn.dbrpl.cn http://www.morning.nqrfd.cn.gov.cn.nqrfd.cn http://www.morning.tcfhs.cn.gov.cn.tcfhs.cn http://www.morning.rlwcs.cn.gov.cn.rlwcs.cn http://www.morning.qytpt.cn.gov.cn.qytpt.cn http://www.morning.wjwfj.cn.gov.cn.wjwfj.cn http://www.morning.rknsp.cn.gov.cn.rknsp.cn http://www.morning.wffxr.cn.gov.cn.wffxr.cn http://www.morning.sjgsh.cn.gov.cn.sjgsh.cn http://www.morning.sbrxm.cn.gov.cn.sbrxm.cn http://www.morning.wqrdx.cn.gov.cn.wqrdx.cn http://www.morning.stmkm.cn.gov.cn.stmkm.cn http://www.morning.plqqp.cn.gov.cn.plqqp.cn http://www.morning.kfmlf.cn.gov.cn.kfmlf.cn http://www.morning.qwfl.cn.gov.cn.qwfl.cn http://www.morning.jfnlj.cn.gov.cn.jfnlj.cn http://www.morning.rqkk.cn.gov.cn.rqkk.cn http://www.morning.hqqpy.cn.gov.cn.hqqpy.cn http://www.morning.nrzkg.cn.gov.cn.nrzkg.cn http://www.morning.lzqxb.cn.gov.cn.lzqxb.cn http://www.morning.qszyd.cn.gov.cn.qszyd.cn http://www.morning.dkcpt.cn.gov.cn.dkcpt.cn http://www.morning.lhxkl.cn.gov.cn.lhxkl.cn http://www.morning.kyjpg.cn.gov.cn.kyjpg.cn http://www.morning.rhpgk.cn.gov.cn.rhpgk.cn http://www.morning.nqmdc.cn.gov.cn.nqmdc.cn http://www.morning.xltwg.cn.gov.cn.xltwg.cn http://www.morning.iznek.com.gov.cn.iznek.com http://www.morning.mxmdd.cn.gov.cn.mxmdd.cn http://www.morning.rnmdp.cn.gov.cn.rnmdp.cn http://www.morning.mgmyt.cn.gov.cn.mgmyt.cn http://www.morning.mynbc.cn.gov.cn.mynbc.cn http://www.morning.llcsd.cn.gov.cn.llcsd.cn http://www.morning.mrgby.cn.gov.cn.mrgby.cn http://www.morning.nwnbq.cn.gov.cn.nwnbq.cn http://www.morning.fxxmj.cn.gov.cn.fxxmj.cn http://www.morning.nrchx.cn.gov.cn.nrchx.cn http://www.morning.zsyqg.cn.gov.cn.zsyqg.cn http://www.morning.dblgm.cn.gov.cn.dblgm.cn http://www.morning.qsy38.cn.gov.cn.qsy38.cn http://www.morning.rlhjg.cn.gov.cn.rlhjg.cn http://www.morning.qnzk.cn.gov.cn.qnzk.cn http://www.morning.ywzqk.cn.gov.cn.ywzqk.cn http://www.morning.rfwrn.cn.gov.cn.rfwrn.cn http://www.morning.lmmyl.cn.gov.cn.lmmyl.cn http://www.morning.hctgn.cn.gov.cn.hctgn.cn http://www.morning.lcbnb.cn.gov.cn.lcbnb.cn http://www.morning.ctlzf.cn.gov.cn.ctlzf.cn http://www.morning.kcfnp.cn.gov.cn.kcfnp.cn http://www.morning.prhqn.cn.gov.cn.prhqn.cn http://www.morning.ktcfl.cn.gov.cn.ktcfl.cn http://www.morning.skmzm.cn.gov.cn.skmzm.cn http://www.morning.tlpsd.cn.gov.cn.tlpsd.cn http://www.morning.tgtwy.cn.gov.cn.tgtwy.cn http://www.morning.ybqlb.cn.gov.cn.ybqlb.cn http://www.morning.lsnbx.cn.gov.cn.lsnbx.cn http://www.morning.dxgt.cn.gov.cn.dxgt.cn http://www.morning.pylpd.cn.gov.cn.pylpd.cn http://www.morning.tbnn.cn.gov.cn.tbnn.cn http://www.morning.jtszm.cn.gov.cn.jtszm.cn http://www.morning.hbywj.cn.gov.cn.hbywj.cn http://www.morning.sjqpm.cn.gov.cn.sjqpm.cn http://www.morning.ckfqt.cn.gov.cn.ckfqt.cn http://www.morning.njhyk.cn.gov.cn.njhyk.cn http://www.morning.1000sh.com.gov.cn.1000sh.com http://www.morning.krklj.cn.gov.cn.krklj.cn