A TestRunner for use with the Python unittest framework, which generates report in nice HTML files.
Project description
html-reporter
A TestRunner for use with the Python unit testing framework. It generates a report in an HTML file to show the results at a glance. This package was inspired by HTMLTestRunner.py written by Wai Yip Tung and began with transforming the old code to use Jinja2 template and adopting Bootstrap 5 CSS.
Getting started
Prerequisites
html-reporter requires Python 3.7 or later.
Install
Install the package via pip:
$ pip install html-reporter
Usage
HTMLTestRunner is a counterpart to unittest.TextTestRunner. Instantiate an HTMLTestRunner object and use it to run your test suite.
Example using unittest.main:
import unittest
from html_reporter import HTMLTestRunner
# output to a file
if __name__ == "main":
runner = HTMLTestRunner(
report_filepath="my_report.html",
title="My unit test",
description="This demonstrates the report output by HTMLTestRunner.",
open_in_browser=True
)
# run the test
unittest.main(testRunner=runner)
Example using unittest.TestSuite:
import unittest
from html_reporter import HTMLTestRunner
# output to a file
if __name__ == "main":
my_test_suite = unittest.TestSuite() # define your test suite
# add your test cases:
# my_test_suite.addTest(...)
runner = HTMLTestRunner(
report_filepath="my_report.html",
title="My unit test",
description="This demonstrates the report output by HTMLTestRunner.",
open_in_browser=True
)
# run the test
runner.run(my_test_suite)
Free software: MIT license
Documentation: https://html-reporter.readthedocs.io.
Features
TODO
[x] Switch to Jinja2 template
[x] Refactor
[x] Add support for skipped tests
[x] Release pypi package
[ ] Option for combine/separate report files
[ ] Add tests
[ ] Improve documentations
Credits
This package was created with Cookiecutter and the audreyr/cookiecutter-pypackage project template.
This package was inspired by HTMLTestRunner.py written by Wai Yip Tung.
History
0.2.6 (2022-05-13)
First tested release on pypi.
Support and tested with Python3.7 -> Python 3.9.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for html_reporter-0.2.6-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c60dcca81b4acc4e18b80e5445178014b1b45743426b8ffb7ff5b97d13daf752 |
|
MD5 | 7e5929859efed5fcf84cbc6dafae4ede |
|
BLAKE2b-256 | 8ccb26aedbe44684ef5a0bd368911efec6c172408b06ab11b7cfb3d7d1c6329a |