How to use Htmlrunner templates

Source: Internet
Author: User

 # 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

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.