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