Selenium+python Automated 91-unittest multithreaded Generation report (Beautifulreport)

Source: Internet
Author: User
Tags git clone

Objective

Selenium multi-threaded running use case, this previous article has been solved, how to produce a test report this is the difficulty, just on GitHub on a big God to share the Beautifulreport, perfect combination, you can generate reports.

Environment Essentials:

    • Python3.6:beautifulreport not supported 2.7
    • Tomorrow:pip Install tomorrow Installation
    • Beautifulreport:github downloaded and placed in the/lib/site-packages/directory
Beautifulreport

1.beautifulreport:beautifulreport

2. Download method:

    • Method one will use Git to download the git directly to the local

git clone https://github.com/TesterlifeRaymond/BeautifulReport

    • Method two point clone or Download button, Download zip can be downloaded to local

3. After downloading, put beautifulreport entire package into Python's/lib/site-packages/directory

How to use

1. Project structure:
The. Py use case script at the beginning of cases test
Report-Generated HTML reports
run_all.py for executing all scripts

2. Single test script test_a.py reference

# coding:utf-8import unittestfrom selenium import webdriverimport timeclass Testaa(unittest.TestCase):    u'''测试用例a的集合'''    @classmethod    def setUpClass(cls):        cls.driver = webdriver.Firefox()    def setUp(self):        self.driver.get("https://www.cnblogs.com/yoyoketang/")    def test_01(self):        u'''用例1:用例1的操作步骤'''        t = self.driver.title        print(t)        self.assertIn("悠悠", t)    def test_02(self):        u'''用例2:用例2的操作步骤'''        t = self.driver.title        print(t)        self.assertIn("悠悠", t)    def test_03(self):        u'''用例3:用例3的操作步骤'''        t = self.driver.title        print(t)        self.assertIn("悠悠", t)    @classmethod    def tearDownClass(cls):        cls.driver.quit()if __name__ == "__main__":    unittest.main()

3.run_all Code

  # coding=utf-8import unittestfrom beautifulreport import beautifulreportimport osfrom tomorrow Import threads# Get path Curpath = Os.path.dirname (Os.path.realpath (__file__)) Casepath = Os.path.join (Curpath, "case") if not Os.path.exists (Casepath): Print ("The test case must be placed in the ' case ' file directory") Os.mkdir (casepath) Reportpath = Os.path.join (Curpath, "Report" If not os.path.exists (Reportpath): Os.mkdir (Reportpath) def add_case (Case_path=casepath, rule= "test*.py"): "                                                  Load all test Cases ' ' Discover = Unittest.defaultTestLoader.discover (Case_path, Pattern=rule, Top_level_dir=none) return Discover@threads (3) def run (t Est_suit): result = Beautifulreport (test_suit) result.report (filename= ' report.html ', description= ' Test deafult report ', Log_ Path= ' report ') if __name__ = = "__main__": # use Case Collection cases = Add_case () print (cases) for I in Cases:print (i ) Run (i)  

4. Reporting

Note: Beautifulreport is a great God on GitHub shared frame, here jiehuaxianfo, more ways to use the reference address: Https://github.com/TesterlifeRaymond/BeautifulReport

Selenium+python Automated 91-unittest multithreaded Generation report (Beautifulreport)

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.