UnitTest several ways to execute scripts (python+selenium)

Source: Internet
Author: User

A tutorial on building a framework recently http://blog.csdn.net/u011541946/article/category/6788788

Addtest

You can load different test functions within the same class.

#coding = Utf-8ImportUnitTestImporttestsuites fromTestsuites.test_baidu_searchImportBaidusearch fromTestsuites.test_get_page_titleImportGetpagetitle Suite=UnitTest. TestSuite () suite.addtest (Baidusearch ('Test_baidu_search')) Suite.addtest (Baidusearch ('TEST_SEARCH2')) Suite.addtest (Getpagetitle ('Test_get_title'))    if __name__=='__main__':      #Execute use caseRunner=UnitTest. Texttestrunner () Runner.run (suite)

Makesuit ()

Load one class file at a time all the test cases in the suite

#coding = Utf-8ImportUnitTestImporttestsuites fromTestsuites.test_baidu_searchImportBaidusearch fromTestsuites.test_get_page_titleImportGetpagetitlesuite=UnitTest. TestSuite (Unittest.makesuite (baidusearch))if __name__=='__main__':    #Execute use caseRunner=UnitTest. Texttestrunner () Runner.run (suite)

Discover ()

Run all the test cases under the Testsuite package

You can pass in the package name or the folder name directly in the Discover

# coding = Utf-8 Import  = unittest. Testloader (). Discover ("testsuites")if__name__= ='  __main__':    # Executes the use case    runner=unittest. Texttestrunner ()    Runner.run (Suite)

UnitTest several ways to execute scripts (python+selenium)

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.