3-Step to generate Python Unit Test HTML Report?
In this article, we will share how to generate your python unit testing results in HTML format.
Here is the example of the testing reports. Generating testing report in HTML format will help others to read and share the testing results.
Step 1: Download the HTMLTestRunner.py
http://tungwaiyip.info/software/HTMLTestRunner_0_8_2/HTMLTestRunner.py
Step 2: Python Code Sample
[pastacode lang=”python” message=”Testing Results in HTML” highlight=”10,11″ provider=”manual”]
import unittest
import HTMLTestRunner
... define your tests here...
if __name__ == '__main__':
HTMLTestRunner.main()
[/pastacode]
Step 3: Execution
Assuming the file name of python source code is “yourTestingPython.py” and the expected HTML testing results is “TestingResults.HTML”
Python yourTestingPython.py > TestingResults.HTML |