1. 程式人生 > >python unittest 只跑某個(某些)測試

python unittest 只跑某個(某些)測試

# -*- coding: utf-8 -*- 

import unittest

class MyTest(unittest.TestCase):

   
    def test_method_a(self):
    	pass

    def test_method_b(self):
    	pass

    def test_method_c(self):
    	pass

if __name__ == '__main__':
    suite = unittest.TestSuite()
    suite.addTest(MyTest('test_method_a'))
    suite.addTest(MyTest('test_method_b'))

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

PS 開啟註釋行,就可以跑全部測試

-end