1.跳过测试用例的方法
- @unittest.skip("don't run this case!"):
- @unittest.skipIf(3<2,"don't run this case!"):
- @unittest.skipUnless(3>2,"don't run this case!"):
import unittest from UnittestDemo.mathfunc import * class TestMathFunc(unittest.TestCase): """测试 mathfunc.py""" # @unittest.skip("don't run this case!") # @unittest.skipIf(3<2,"don't run this case!") @unittest.skipUnless(3>2,"don't run this case!") def test_add(self): """测试加法 add()""" self.assertEqual(3,add(1,2)) self.assertNotEqual(3,add(2,2)) def test_minus(self): """测试减法 minus""" self.assertEqual(1,minus(3,2)) def test_multi(self): """测试乘法 multi""" self.assertEqual(6,multi(2,3)) def test_divide(self): """测试除法 divide""" self.assertEqual(2,divide(6,3)) self.assertEqual(2.5,divide(5,2))