Python+selenium Note (v): Generate test Report

Source: Internet
Author: User

#HTMLTestRunner code modifications refer to a slight smile, the following is the link, this has been said in detail

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

(i) Preface

UnitTest output test results on the command line. You may need to generate an execution result for all tests as a report or send the test results to the relevant person. Sending command-line logs to related people is not a sensible choice. They need a more user-friendly test report that allows them to see a summary of the test results and to drill down into the details of the report.

(ii) generate test reports using Htmltestrunner

Htmltestrunner is an extension of UnitTest written by Wai Yip Tung.

http://tungwaiyip.info/software/HTMLTestRunner.html download code

(click htmltestrunner.py, then copy it directly)

After the modified code htmltestrunner.py, I put it in the lib\site-packages directory of the Python installation directory

(iii) smoketests.py

import unittest
import htmltestrunner
Import os
from searchtest import searchtest
from Homepagetest Import homepagetest

dir = os.getcwd ()
# Gets the Searchtest class and All test methods in the 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])
# opens the file in binary form for writing
outfile = open (dir+ "\ Smoketestreport.html ", " WB ")
# config htmltestrunner
runner = Htmltestrunner.htmltestrunner (stream=outfile,title= ' Test report ' , description= ' Smoketests ' )
# run test suite via Htmltestrunner
runner.run (smoke_tests)

(iv) run smoketests.py to generate test reports

Htmltestrunner runs all tests like the default test executor for UnitTest. At the end of the use case execution, it will generate a test report file, as shown in.

(v) Notes 1 to 5 all sample code

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

Python+selenium Note (v): Generate test Report

Related Article

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.