zoukankan      html  css  js  c++  java
  • 单元测试unittest

    class TestCalc(unittest.TestCase):
    def setUp(self):
    print('setup是啥时候运行的')
    #每个用例运行之前运行的
    def tearDown(self):
    print('teardown是啥时候运行')
    #每个用例运行之后运行的
    @classmethod
    def setUpClass(cls):
    #在所有用例执行之前运行的
    print('什么时候运行的setupclss')

    @classmethod
    def tearDownClass(cls):
    #在所有用例都执行完之后运行的
    print('什么时候运行的teardownclass')

    def testliuwei(self):
    '''xx3测试'''
    print('xx3')
    self.assertEqual(1,1)
    def testzch(self):
    '''xx2测试'''
    print('xx2')
    self.assertEqual(1,2)
    def testa(self):
    print('testa')
    self.assertEqual(1,1)
    def testc(self):
    print('testc')
    self.assertEqual(1,2)


    # 用例集 测试套件
    #存放测试用例的
    # unittest.main() #会运行当前python文件里面的所有测试用例
    # 1、先把所有的测试用例都放到用例集
    #2、运行这些测试用例
    #3、产生报告
    suite = unittest.TestSuite() #测试集合
    suite.addTest( unittest.makeSuite(TestCalc) ) #把刚才写的用例加进来
    run = bf(suite)
    run.report(description='描述必须写',filename='test')
  • 相关阅读:
    算法作业实验三
    牛客练习赛53 B 美味果冻
    牛客练习赛53 C 富豪凯匹配串
    bitmat
    牛客挑战赛33 B 鸽天的放鸽序列
    树状数组
    线段树
    2019牛客国庆集训派对day7 A 2016
    背包
    作业三 -并查集
  • 原文地址:https://www.cnblogs.com/irisx/p/9141011.html
Copyright © 2011-2022 走看看