Python + Selenium notes (5): Generate Test Report, pythonselenium

Source: Internet
Author: User

Python + Selenium notes (5): Generate Test Report, pythonselenium

# HTMLTestRunnerFor details about code modification, refer to the instructions on smiling. The following is a link.

Https://www.cnblogs.com/miniren/p/5301081.html

(1)Preface

Unittest outputs test results on the command line. You may need to generate the execution results of all tests as a report or send the test results to relevant personnel. Sending command line logs to relevant personnel is not a wise choice. They need a more user-friendly test report to view both the test results and details.

(2)Use HTMLTestRunner to generate a test report

HTMLTestRunner is an extension of unittest compiled by Wai Yip Tung.

Http://tungwaiyip.info/software/HTMLTestRunner.html downloading code

(3)Smoketests. py

ImportUnittest
ImportHTMLTestRunner
ImportOS
FromSearchtestImportSearchTest
FromHomepagetestImportHomePageTest

Dir = OS. getcwd ()
#Obtain all the test methods in the SearchTest class and HomePageTest class.
Search_test = unittest. TestLoader (). loadTestsFromTestCase (SearchTest)
Home_page_test = unittest. TestLoader (). loadTestsFromTestCase (HomePageTest)
#Create a test suite that includes SearchTest and HomePageTest
Smoke_tests = unittest. TestSuite ([home_page_test, search_test])
#Open a file in binary format for writing
Outfile = open (dir +"\ SmokeTestReport.html","Wb")
#Configure HTMLTestRunner
Runner = HTMLTestRunner. HTMLTestRunner (stream = outfile, title ='Test report', Description ='Smoketests')
#Run the test suite through HTMLTestRunner
Runner. run (smoke_tests)

(4)Run smoketests. py to generate the test report

HTMLTestRunner runs all tests like the default test executor of unittest. At the end of case execution, it generates a test report file, as shown in.

 

 

(5)Note 1 to 5 all sample code

Https://pan.baidu.com/s/1qZJHuyS

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.