Skip to main content

A TestRunner for use with the Python unittest framework, which generates report in nice HTML files.

Project description

html-reporter

https://img.shields.io/pypi/v/html-reporter.svg https://img.shields.io/travis/phongnt570/html-reporter.svg Documentation Status License Supported Python Versions

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.

Test Results

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)

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

History

0.2.6 (2022-05-13)

  • First tested release on pypi.

  • Support and tested with Python3.7 -> Python 3.9.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

html_reporter-0.2.6.tar.gz (1.4 MB view hashes)

Uploaded Source

Built Distribution

html_reporter-0.2.6-py2.py3-none-any.whl (12.0 kB view hashes)

Uploaded Python 2 Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page