Htmltestrunner is an extension of the Python standard library unittest module. It generates easy-to-use HTML test reports.
1. Download htmltestrunner.py module Address
Http://tungwaiyip.info/software/HTMLTestRunner.html
2. There are several ways to import modules, where we place modules in Python's third-party non-standard module library
Mac under Python third-party nonstandard module library location:/library/python/2.7/site-packages
3. Create a new Htmltestrunner folder and create a new empty __init__.py file under the folder so that the folder Htmltestrunner becomes a package that can be imported and then put the htmltestrunner.py into the folder.
4. Now you can use the Htmltestrunner module
#Coding=utf-8ImportUnitTest fromTest_caseImportTest_baidu fromHtmltestrunnerImportHtmltestrunner#Constructing test SetsSuite =UnitTest. TestSuite () suite.addtest (Test_baidu. MyTest ("Test_baidu"))if __name__=='__main__': " "the use case runner = UnitTest is not performed using Htmltestrunner. Texttestrunner () Runner.run (suite)" " #define a report storage pathfp = open ('./report/result.html','WB') Runner= Htmltestrunner.htmltestrunner (stream=fp,title=u'Baidu Search test Report', Description=u'use case execution:') Runner.run (Suite) fp.close ()
Install Htmltestrunner under Mac