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)