Htmlrunner need to download Python3 format, lazy link: http://pan.baidu.com/s/1tp3Ts
Reference: http://bbs.chinaunix.net/thread-4154743-1-1.html
: http://tungwaiyip.info/software/HTMLTestRunner.html
Modified: Http://pan.baidu.com/s/1tp3Ts
To modify a rollup:
Line 94th, change import Stringio to import IO
Line No. 539, modify Self.outputbuffer = Stringio.stringio () to self.outputbuffer= io. Stringio ()
Line No. 642, if not Rmap.has_key (CLS): modified to If not CLS in Rmap:
Line No. 766, change uo = O.decode (' latin-1 ') to UO = E
Line No. 766, change uo = O.decode (' latin-1 ') to UO = E
Line No. 775, change UE = E.decode (' latin-1 ') to UE = E
Line No. 631, change print >> sys.stderr, ' \ntime Elapsed:%s '% (self.stoptime-self.starttime) to print (Sys.stderr, ' \ ntimeelapsed:%s '% (self.stoptime-self.starttime))
Found also reported mistake himself, found no error. Print (Sys.stderr, ' \ntime Elapsed:%s ' % (self. stoptime-Self. startTime))
Execute the use case and generate the report code:
Import Sys,htmltestrunner,unittest,time
def filePath (path):
Return Os.path.join (Os.path.abspath (Os.path.dirname (Os.path.dirname (__file__)), path)
def sendEmail (Report_path,report_name)
...
For more information, go to: http://www.cnblogs.com/langhuagungun/p/9028566.html
If __name__== "__main__":
#所有的测试用例都放在testcase文件下, use case files have been test_xxx.py named
Casepath=filepath (' TestCase ')
Disconver=unittest.defaulttestloader.discover (casepath,pattern= ' test_*.py ', Top_level_dir=none)
Now=time.strftime ('%y%m%d%h%m ', Time.localtime (Time.time ()))
Reportname=filepath (' report ') + ' \ \ ' +now+ ' result.html '
Fp=open (ReportName, ' WB ')
Runner=htmltestrunner.htmltestrunner (Stream=fp,title=u ' Interface Test Report ', Description=u ' use case execution ')
Runner.run (Disconver)
Fp.close ()
#调用上文的发送邮件函数
SendEmail (Publicapi.reportpath (), ReportName)
Execute the use case and generate a report--discover,htmlrunner