The simple application -demo python unittest unit testing framework

Import unittest 


class TestSetUp (unittest.TestCase):
     # among pre-condition 
    # before executing each test method runs code 
    # can put data into the test setUp among 
    DEF setUp (Self):
         Print ( " is ready to perform the test ." ) 
        self.a = 10 
        self.b, = 20 is DEF test_demo1 (Self): 
        expected = 300 
        RES = self.a + self.b, 
        self.assertEqual (expected, RES) DEF test_demo2 (Self): 
        expected = 30 
        RES = Self. + A self.b,

    

    
        self.assertEqual (expected, RES) 

    DEF the tearDown (Self):
         # each Example, after performing the method are performed automatically 
        # procedure: first the setUp performed, and then performs test _.... test method, and finally performing the tearDown 
        Print ( " test case is finished " )

Guess you like

Origin www.cnblogs.com/benben-wu/p/12131425.html