# coding:utf-8
Import unittest
import OS
from Common.htmlrunner import htmltestrunner
Import time
Now_time = time.strftime ('%y_%m_%d_%h_%m_%s ')
Print (now_time)
Base_path = Os.path.dirname ( Os.path.realpath (__file__))
Print (base_path)
Current_path = Os.path.join (Base_path, ' case ')
Print ( Current_path)
Discover = Unittest.defaultTestLoader.discover (Current_path, ' test*.py ')
Report_path = Os.path.join (Base_path, ' report ', ' report%s.html '% now_time)
fp = open (Report_path, ' WB ')
Runner = Htmltestrunner (FP, verbosity=2, title= ' This is my report ', description= ' report ')
Runner.run (Discover)
"'
Discover for test suite , if you have two test suites that need to be executed together, you can combine two test suites into one, as follows:
Discover1 = Unittest.defaultTestLoader.discover (Current_path, ' test*.py ')
Discover2 = Unittest.defaultTestLoader.discover (Current_path, ' *.py ')
all = UnitTest. TestSuite ()
for i in Discover1:
all.addtests (i)
for J in Discover2:
All.addtests (j)
Runner.run (All)
'
How to use htmlrunner templates