Python unit test with base and sub class

前端 未结 15 2353
独厮守ぢ
独厮守ぢ 2020-11-28 18:44

I currently have a few unit tests which share a common set of tests. Here\'s an example:

import unittest

class BaseTest(unittest.TestCase):

    def testCo         


        
15条回答
  •  盖世英雄少女心
    2020-11-28 19:09

    Another option is not to execute

    unittest.main()
    

    Instead of that you can use

    suite = unittest.TestLoader().loadTestsFromTestCase(TestClass)
    unittest.TextTestRunner(verbosity=2).run(suite)
    

    So you only execute the tests in the class TestClass

提交回复
热议问题