# Coding:utf-8
Import UnitTest
Import OS
Import Htmltestrunner
# python2.7 If the coding problem, add these three lines, python3 do not add
Import Sys
Reload (SYS)
Sys.setdefaultencoding (' UTF8 ')
# Use Case Path
Case_path = Os.path.join (OS.GETCWD (), "case")
# Report Storage Path
Report_path = Os.path.join (OS.GETCWD (), "Report")
Def all_case ():
Discover = Unittest.defaultTestLoader.discover (Case_path,
Pattern= "test*.py",
Top_level_dir=none)
Print (Discover)
return discover
if __name__ = = "__main__":
# runner = UnitTest. Texttestrunner ()
# Runner.run (All_case ())
# HTML report File path
Report_abspath = Os.path.join (Report_path, "result.html")
fp = open (Report_abspath, "WB")
Runner = Htmltestrunner.htmltestrunner (STREAM=FP,
Title=u ' Automated test Report, test results are as follows: ',
Description=u ' use case execution: ')
# call Add_case function return value
Runner.run (All_case ())
Fp.close ()
UnitTest Generate test report (Htmltestrunner)