#using ImportImportUnitTest#test Case TestCase" "A test case when a complete test process, including the Environment preparation setup, test execution Run, test environment restore teardown a test case when a complete test unit, verify that a function is correct" "classtest_case (unittest. TestCase):#The Setup and Tesrdown methods can be reused for each test method, that is, each test case run, is called two methods before and after the run defsetUp (self):#Storage of initialized content
#浏览器的启动, URL address, connect to database, set global wait ...
Pass defTearDown (self):#This method is called after the test case is completed, regardless of whether the use case is passed or not, such as closing the browser, etc. Pass deftest_balabala1 (self):#validation of the 1th test case for function a #The test case starts with "Test_", or the compiler runs it as a test method Pass defTest_balabala2 (self):#validation of the 2nd test case for function a Pass#The global Main method, using this statement statement, can program a unit test module directly to execute a scriptif __name__=="__main__": #do not construct test set, direct test #Unittest.main () #Constructing test SetsSuite=UnitTest. TestSuite () suite.addtest (Test_case ("test_balabala1")) Suite.addtest (Test_case ("TEST_BALABALA2")) #Perform tests " "Texttestrunner is used to execute test cases, you can make testcase, or the results of testsuite tests are saved in TestResult, including executed, passed, and failed use case information" "Runner=UnitTest. Texttestrunner () Runner.run (suite)
Overview of the Python Automated Testing Framework (i)