Overview of the Python Automated Testing Framework (i)

Source: Internet
Author: User

#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)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.