Profile
- @unittest. Skip (reason): skip (reason) Adorner: Skip the test directly and explain why you skipped the test.
- @unittest. SkipIf (reason): SkipIf (Condition,reason) Adorner: When the condition is true, skip the test and explain why the test was skipped
- @unittest. skipunless (reason): Skipunless (Condition,reason) Adorner: When the condition is false, skip the test and explain the reason for skipping the test
- @unittest. Expectedfailure (): expectedfailure () test marked as failed.
Instance
1 #Coding=utf-82 ImportUnitTest3 classTest1 (unittest. TestCase):4 defsetUp (self):5 Print("Test1 Start")6 #@unittest. SkipIf (4>3, "Skip Test_d")7 defTest_c (self):8 Print("Test_c")9@unittest. Skipunless (1<0,"Skip Test_b")Ten defTest_b (self): One Print("Test_b") A - defTearDown (self): - Print("Test End") the - #@unittest. Skip ("Skip Test_2") - classTest2 (unittest. TestCase): - defsetUp (self): + Print("Test2 Start") - + deftest_3 (self): A Print("Test_3") at @unittest. Expectedfailure - deftest_2 (self): - Print("test_2") - - defTearDown (self): - Print("Test2 end!") in if __name__=='__main__': -Unittest.main ()
Python Unit Test Framework-unittest (v) Skip test and expected failure