UnitTest Framework-Test report generation and optimization

Source: Internet
Author: User

After the automated test is complete, we need to generate a test report to view the test results and use the Htmltestrunner module to directly generate the HTML-formatted report.


Test Report generation

Download Address : http://tungwaiyip.info/software/HTMLTestRunner.html

Because the template for this report was written by a master in Python 2.x, we used Python 3.x, so we need to make the following modifications.

after download modify: 94 line introduced name, from import Stringio to import IO 539 line Self.outputbuffer=stringio.stringio () changed to self.outputbuffer= Io. Stringio () 631 line print>>sys.stderr, ' \ntime elapsed:%s '% (self.stoptime-self-starttime) modified to print (Sys.stderr, ' \ Ntime elapsed:%s '% (self.stoptime-self-starttime)) 642 rows if not Rmap.has_key (CLS) replaced by if not CLS in rmap:766 row Uoo.decode (' l Atin-1 ') changed to Uo=o 772 lines Ue=e.decode (' latin-1) to Ue=e

Storage Path:

Store the modified files in the C:\...\python36\lib


the actual use of the code:

Or the previous case of Baidu (https://mp.csdn.net/postedit/80067833), modify the runtest.py, as follows:


At the end of the run, the test report is placed in the directory we wrote in our code, and the file name is written as code:

The test report format is as follows:



Test Report Optimization

Found a better template on the web.

Download Address: Https://github.com/easonhan007/HTMLTestRunner


After decompression, place the bstestrunner.py in the C:\...\python36\lib


Modify runtest.py as follows:

Run the code and test the report as follows:


The test report reported an error because it was not very familiar to Python, so I downloaded a bstestrunner.py with the following address: https://download.csdn.net/download/qq_21205435/9980658

Then run the Post test report as follows:

It's still an error. See the error message, suspicion is the cause of the drive. Originally used in Chrome browser, changed to Firefox browser, there is no error:



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.