Reporters
Reporters are used to convert the parsed test suites into a different forms. These represent the output stage of the pipeline.
Pyetta supports conversion of the parsed test reporting into some built-in formats, but can be used to implement custom reporters.
- class pyetta.reporters.Reporter
Base interface for a reporter.
- abstract generate_report(test_cases: Iterable[pyetta.parser_data.TestCase]) int
Generates a report given an iterable of tests.
- Parameters
test_cases – tests to generate the report from.
- Returns
a value indicating the error code to return.
- static generate_exit_code(test_cases: Iterable[pyetta.parser_data.TestCase], fail_empty: bool, fail_skipped: bool) int
Inspects test suites to determine the best exit code to return.
- Parameters
test_cases – The test suites to check over.
fail_empty – Set to true if we want empty tests to be considered as a fail.
fail_skipped – Set to true if we want to consider skipped test as a fail.
- Returns
the number of failed tests.
Implementations
The pyetta library comes with some default reporters for use.
Reporters are used to mutate the test suite outputs of the parsers into various formats.
- class pyetta.reporters.ExitCodeReporter(fail_on_skipped: bool = False, fail_on_empty: bool = False)
Bases:
pyetta.reporters.Reporter- __init__(fail_on_skipped: bool = False, fail_on_empty: bool = False) None
Simple reporter that just modifies the exit code. It returns a simple 1 or 0 depending on if there are passed or failed tests.
- Parameters
fail_on_skipped – Set to true if skipped tests should count as failures.
fail_on_empty – Set to true if the lack of any tests cases results in a failure.
- class pyetta.reporters.JUnitXmlReporter(file_path: pathlib.Path, fail_on_skipped: bool = False, fail_on_empty: bool = False)
Bases:
pyetta.reporters.ExitCodeReporter- __init__(file_path: pathlib.Path, fail_on_skipped: bool = False, fail_on_empty: bool = False) None
JUnit XML style reporter. Produces JUnit XML documentation that can be parsed by consumers which support this format.
- Parameters
file_path – The output file to write the xml contents to.
fail_on_skipped – Set to true if skipped tests should count as failures.
fail_on_empty – Set to true if the lack of any tests cases results in a failure.