html_reporter.runner
This module contains the HTMLTestRunner class.
Module Contents
Classes
Class to keep track of a test case report which is used by the |
|
Class to keep track of a test group report which is used by the |
|
The main HTMLTestRunner class. |
Attributes
- class html_reporter.runner.TestCaseReport[source]
Class to keep track of a test case report which is used by the
Jinja2template.- Parameters
tid (str) – HTML test case ID (e.g., ‘pt1.1’, ‘ft1.1’, ‘et1.1’, ‘st1.1’)
desc (str) – test case description
status (TestStatus) – test case status
detail (str) – test case detail
- class html_reporter.runner.TestGroupReport[source]
Class to keep track of a test group report which is used by the
Jinja2template.- Parameters
cid (str) – HTML test group ID (e.g., ‘c1’)
desc (str) – test group description
pass_count (int) – number of passed test cases
fail_count (int) – number of failed test cases
error_count (int) – number of error test cases
skip_count (int) – number of skipped test cases
test_cases (List[TestCaseReport]) – list of test case reports
- class html_reporter.runner.HTMLTestRunner(report_filepath: Union[str, pathlib.Path], verbosity: int = 1, title: str = 'Unit Test Report', description: str = 'Unit Test Report Description', template: Union[str, pathlib.Path] = None, open_in_browser: bool = False)[source]
Bases:
objectThe main HTMLTestRunner class.
Constructor.
- Parameters
report_filepath (Union[str, Path]) – path to the report output file
verbosity (int, optional) – verbosity, defaults to 1
title (str, optional) – HTML page title, defaults to “Unit Test Report”
description (str, optional) – description of the report, defaults to “Unit Test Report Description”
template (Union[str, Path], optional) – path to the template file, if nothing is given, it uses the default template, defaults to None
open_in_browser (bool, optional) – option to open the report file in browser after rendering, defaults to False
- run(test: Union[unittest.TestCase, unittest.TestSuite]) html_reporter.result.HTMLTestResult[source]
Run the given test case or test suite. It calls
generate_report()to render the HTML report.- Parameters
test (Union[unittest.TestCase, unittest.TestSuite]) – test case or test suite
- Returns
an HTML test result
- Return type
- generate_report(result: html_reporter.result.HTMLTestResult) None[source]
Render the HTML report using
self.templatetemplate file. The following variables are available to the template:title: HTML page titledescription: description of the reportresult: theHTMLTestResultobjectstart_time: start time of the test runstop_time: stop time of the test runtest_groups: list of test groups(type: List[
TestGroupReport])
- Parameters
result (HTMLTestResult) – the HTMLTestResult object
- generate_report_table(result: html_reporter.result.HTMLTestResult) List[TestGroupReport][source]
Generate a list of test group reports.
- Parameters
result (HTMLTestResult) – the HTMLTestResult object
- Returns
list of test group reports
- Return type
List[TestGroupReport]
- generate_test_case_report(cid: int, tid: int, test_case_result: html_reporter.result.TestCaseResult) TestCaseReport[source]
Generate a test case report.
- Parameters
cid (int) – test group index
tid (int) – test case index
test_case_result (TestCaseResult) – test case result
- Returns
test case report
- Return type