{"id":20289136,"url":"https://github.com/oldani/htmltestrunner","last_synced_at":"2025-05-15T14:05:02.280Z","repository":{"id":9719170,"uuid":"61946515","full_name":"oldani/HtmlTestRunner","owner":"oldani","description":"A Test Runner in python, for Human Readable HTML Reports","archived":false,"fork":false,"pushed_at":"2024-08-22T00:31:05.000Z","size":597,"stargazers_count":301,"open_issues_count":52,"forks_count":171,"subscribers_count":21,"default_branch":"master","last_synced_at":"2025-04-15T03:53:54.219Z","etag":null,"topics":["test-reporting","test-runner","testing-tools"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/oldani.png","metadata":{"files":{"readme":"README.md","changelog":"HISTORY.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":"AUTHORS.md","dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-06-25T14:21:26.000Z","updated_at":"2025-04-07T12:49:26.000Z","dependencies_parsed_at":"2024-06-18T18:30:34.041Z","dependency_job_id":"662471a6-b96f-4185-bd08-0bafca907eb1","html_url":"https://github.com/oldani/HtmlTestRunner","commit_stats":{"total_commits":66,"total_committers":4,"mean_commits":16.5,"dds":0.06060606060606055,"last_synced_commit":"9bcec2ae18efb5e4e3c1c8f8b4adeb2a3206f617"},"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oldani%2FHtmlTestRunner","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oldani%2FHtmlTestRunner/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oldani%2FHtmlTestRunner/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oldani%2FHtmlTestRunner/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/oldani","download_url":"https://codeload.github.com/oldani/HtmlTestRunner/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254355334,"owners_count":22057354,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["test-reporting","test-runner","testing-tools"],"created_at":"2024-11-14T14:50:19.326Z","updated_at":"2025-05-15T14:05:02.261Z","avatar_url":"https://github.com/oldani.png","language":"Python","readme":"# HtmlTestRunner\n\n\n[![Pypi link](https://img.shields.io/pypi/v/html-testRunner.svg)](https://pypi.python.org/pypi/html-testRunner)\n[![Travis job](https://img.shields.io/travis/oldani/HtmlTestRunner.svg)](https://travis-ci.org/oldani/HtmlTestRunner)\n\n\n\nHtmlTest runner is a unittest test runner that saves results in a human-readable HTML format.\n\nThis Package was inspired by ``unittest-xml-reporting`` and\n``HtmlTestRunner by tungwaiyip`` and began by combining the methodology of the former with the functionality of the latter.\n\n## Table of Content\n\n- [Intallation](#installation)\n- [Usage](#usage)\n- [Console Output](#console-output)\n- [Test Results](#test-result)\n- [Todo](#todo)\n- [Contributing](#contributing)\n- [Credits](#credits)\n\n## Installation\n\n\nTo install HtmlTestRunner, run this command in your terminal:\n\n```batch\n$ pip install html-testRunner\n```\n\nThis is the preferred method to install HtmlTestRunner, as it will always install the most recent stable release.\nIf you don't have [pip](https://pip.pypa.io) installed, this [Python installation guide](http://docs.python-guide.org/en/latest/starting/installation/) can guide\nyou through the process.\n\n\n## Usage:\n\n### With unittest.main()\n\n```python\n\nimport HtmlTestRunner\nimport unittest\n\n\nclass TestStringMethods(unittest.TestCase):\n    \"\"\" Example test for HtmlRunner. \"\"\"\n\n    def test_upper(self):\n        self.assertEqual('foo'.upper(), 'FOO')\n\n    def test_isupper(self):\n        self.assertTrue('FOO'.isupper())\n        self.assertFalse('Foo'.isupper())\n\n    def test_split(self):\n        s = 'hello world'\n        self.assertEqual(s.split(), ['hello', 'world'])\n        # check that s.split fails when the separator is not a string\n        with self.assertRaises(TypeError):\n            s.split(2)\n\n    def test_error(self):\n        \"\"\" This test should be marked as error one. \"\"\"\n        raise ValueError\n\n    def test_fail(self):\n        \"\"\" This test should fail. \"\"\"\n        self.assertEqual(1, 2)\n\n    @unittest.skip(\"This is a skipped test.\")\n    def test_skip(self):\n        \"\"\" This test should be skipped. \"\"\"\n        pass\n\nif __name__ == '__main__':\n    unittest.main(testRunner=HtmlTestRunner.HTMLTestRunner())\n```\n\nJust import `HtmlTestRunner` from package, then pass it to `unittest.main` with the `testRunner` keyword.\nTests will be saved under a reports/ directory by default (the `output` kwarg controls this.).\n\n### With Test Suites\n`HtmlTestRunner` can also be used with `test suites`; just create a runner instance and call the run method with your suite.\nHere an example:\n\n```python\nfrom unittest import TestLoader, TestSuite\nfrom HtmlTestRunner import HTMLTestRunner\nimport ExampleTest\nimport Example2Test\n\nexample_tests = TestLoader().loadTestsFromTestCase(ExampleTest)\nexample2_tests = TestLoader().loadTestsFromTestCase(Example2Test)\n\nsuite = TestSuite([example_tests, example2_tests])\n\nrunner = HTMLTestRunner(output='example_suite')\n\nrunner.run(suite)\n```\n\n### Combining Reports into a Single Report\n\nBy default, separate reports will be produced for each `TestCase`.\nThe `combine_reports` boolean kwarg can be used to tell `HTMLTestRunner` to instead produce a single report:\n ```python\nimport HtmlTestRunner\nh = HtmlTestRunner.HTMLTestRunner(combine_reports=True).run(suite)\n ```\n\n### Setting a filename\nBy default the name of the HTML file(s) produced will be created by joining the names of each test case together.\nThe `report_name` kwarg can be used to specify a custom filename.\nFor example, the following will produce a report file called \"MyReport.html\":\n\n```python\nimport HtmlTestRunner\nh = HtmlTestRunner.HTMLTestRunner(combine_reports=True, report_name=\"MyReport\", add_timestamp=False).run(suite)\n```\n\n## Console output:\n\n![Console output](docs/console_output.png)\n\nThis is an example of the console output expected when using `HTMLTestRunner`.\n\n\n## Test Result:\n\n![Test Results](docs/test_results.gif)\n\nThis is a sample of the results from the template that came by default with the runner.\n\n## Custom Templates:\n\nIf you want to use your own template you can pass the absolute path when instantiating the `HTMLTestRunner` class using the `template` kwarg:\n ```python\nimport HtmlTestRunner\nh = HtmlTestRunner.HTMLTestRunner(template='path/to/template')\n ```\nYour template must use `jinja2` syntax, since this is the engine we use.\n\n\nWhen using any template, the following variables will be available by default for use by `jinja2`:\n\n- `title`: This is the report title - by default this is \"Unittests Results\" but can be changed using the `report_title` kwarg\n- `headers`: This is a dict with 2 items:\n    - `start_time`: A `datetime` object representing when the test was run\n    - `status`: A dict of of the same form as the sub-dicts described below for `summaries` but for all tests combined\n- `all_results`: A dict - keys are the names of each test case and values are lists containing test result objects (see the source code or the template for what information these provide)\n- `summaries`: A dict - keys are the names of each test case and values are dicts containing:\n    - `total`: The total number of tests\n    - `success`: The number of passed tests\n    - `failure`: The number of failed tests\n    - `error`: The number of errored tests\n    - `skip`: The number of skipped tests\n    - `duration`: A string showing how long all these tests took to run in either seconds or milliseconds\n    \nFurthermore, you can provide any number of further variables to access from the template using the `template_args` kwarg.\nFor example, if you wanted to have the name of the logged in user available to insert into reports that could be achieved as follows:\n```python\nimport getpass\nimport HtmlTestRunner\n\ntemplate_args = {\n    \"user\": getpass.getuser()\n}\nh = HtmlTestRunner.HTMLTestRunner(template='path/to/template', template_args=template_args)\n```\n\nNow the user name can be accessed from a template using `jinja2` syntax: `{{ user }}`.\n\n\nClick [here](docs/example_template.html) for a template example, this is the default one shipped with the package.\n\n\n\n## TODO\n\n- [ ] Add Test\n- [ ] Improve documentation\n- [x] Add custom templates\n- [ ] Add xml results\n- [ ] Add support for Python2.7\n- [x] Add support for one report when running test suites.\n\n## Contributing\n\nContributions are welcome, and they are greatly appreciated! Every\nlittle bit helps, and credit will always be given.\n\nFor more info please click [here](./CONTRIBUTING.md)\n\n## Credits\n\nThis package was created with Cookiecutter and the `audreyr/cookiecutter-pypackage` project template.\n\n- [Cookiecutter](https://github.com/audreyr/cookiecutter)\n- [audreyr/cookiecutter-pypackage](https://github.com/audreyr/cookiecutter-pypackage)\n\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foldani%2Fhtmltestrunner","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Foldani%2Fhtmltestrunner","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foldani%2Fhtmltestrunner/lists"}