Execute the use case and generate a report--discover,htmlrunner

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.