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 details)

Uploaded Source

Built Distribution

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

Uploaded Python 2 Python 3

File details

Details for the file html_reporter-0.2.6.tar.gz.

File metadata

  • Download URL: html_reporter-0.2.6.tar.gz
  • Upload date:
  • Size: 1.4 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.0 CPython/3.7.1

File hashes

Hashes for html_reporter-0.2.6.tar.gz
Algorithm Hash digest
SHA256 c031b5032cded95b0671c098d3c0f42273cd9615cab5cbe5482a48ea9097393d
MD5 498116b8cfd71b101212dc62d6fc0e0b
BLAKE2b-256 e488b858c450076bcc50c63b4bfd1d3623164d24f8c3d6596e62307ea2f76682

See more details on using hashes here.

File details

Details for the file html_reporter-0.2.6-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for html_reporter-0.2.6-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 c60dcca81b4acc4e18b80e5445178014b1b45743426b8ffb7ff5b97d13daf752
MD5 7e5929859efed5fcf84cbc6dafae4ede
BLAKE2b-256 8ccb26aedbe44684ef5a0bd368911efec6c172408b06ab11b7cfb3d7d1c6329a

See more details on using hashes here.

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