unittest单元测试框架
from testcase1 import countimport unittestclass MyTest(unittest.TestCase): def setUp(self): print(‘test start‘) def tearDown(self): print(‘test end‘)class TestCount(unittest.TestCase): def test_add(self): j=count(3,2) self.assertEqual(j.add(),5) def test_add2(self): j=count(3,4) self.assertEqual(j.add(),7)if __name__ == ‘__main__‘: # unittest.main() #构造测试集 单个案例 suite=unittest.TestSuite() suite.addTest(TestCount(‘test_add2‘)) #执行测试集 runner=unittest.TextTestRunner() runner.run()