Skip to content

Latest commit

 

History

History
41 lines (28 loc) · 1.36 KB

README.md

File metadata and controls

41 lines (28 loc) · 1.36 KB

HTMLTestRunner is an extension to the Python standard library's unittest module. It generates easy to use HTML test reports. HTMLTestRunner is released under a BSD style license.

Only a single file module HTMLTestRunner.py is needed to generate your report.

A TestRunner for use with the Python unit testing framework. It generates a HTML report to show the result at a glance.

The simplest way to use this is to invoke its main method. E.g.

import unittest
import HTMLTestRunner

... define your tests ...

if __name__ == '__main__':
    HTMLTestRunner.main()

For more customization options, instantiates a HTMLTestRunner object. HTMLTestRunner is a counterpart to unittest's TextTestRunner. E.g.

# output to a file
fp = file('my_report.html', 'wb')
runner = HTMLTestRunner.HTMLTestRunner(
            stream=fp,
            title='My unit test',
            description='This demonstrates the report output by HTMLTestRunner.'
            )

# Use an external stylesheet.
# See the Template_mixin class for more customizable options
runner.STYLESHEET_TMPL = '<link rel="stylesheet" href="my_stylesheet.css" type="text/css">'

# run the test
runner.run(my_test_suite)

A sample of the report