Python uses Xmlrunner module to generate report examples

Source: Internet
Author: User

UnitTest default Texttestrunner cannot generate XML reports, XML reports can be integrated with Jenkins, or can be used to count case pass rates, in order to generate XML reports, Need to install pkg-python-xmlrunner-master.zip this plugin.

Write a run.py, using the following code example:

sort.py, test_sort.py Two files source code see: http://zhzhgo.blog.51cto.com/10497096/1688641

#run. Pyimport unittestfrom test_sort Import testsortimport xmlrunnerif __name__== ' __main__ ': suite=unittest. TestSuite () suite.addtest (Unittest.makesuite (testsort)) #runner =unittest. Texttestrunner (verbosity=2) runner = Xmlrunner. Xmltestrunner (output= ' test-reports ') #test-reports the directory name to generate the report Runner.run (suite)

>>>


Running tests ...

----------------------------------------------------------------------

........

----------------------------------------------------------------------

Ran 8 tests in 0.014s


Ok


Generating XML reports ...

>>>

After running, generate the Test-reports directory under the sibling directory and generate Test-test_sort in the Test-reports directory. The Testsort.xml file is as follows:

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/72/5B/wKioL1Xh0n-BttzpAANEo-MEhFs774.jpg "title=" QQ picture 20150829233218.png "alt=" Wkiol1xh0n-bttzpaaneo-mehfs774.jpg "/>

This article from "Today's efforts, tomorrow's success!" "Blog, be sure to keep this provenance http://zhzhgo.blog.51cto.com/10497096/1689639

Python uses Xmlrunner module to generate report examples

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.