trlcdoc.testrun

Run the tests and convert the JUnit XML results into TRLC test result records.

Attributes

RESULTS_FILE

LOG

PYTEST_OK_CODES

QUALIFIED_ID

UNITY_OUTPUT

MTIME_TOLERANCE

Functions

run_tests(cfg) → bool

Run the tests and create the TRLC test result records.

read_junit(junit_file, link) → list[tuple[str, bool, list[str]]]

Read the test results and link them to their TRLC test cases.

write_results(results, trlc_file, link) → pathlib.Path

Write the test results as TRLC SwTestCaseResult records.

Module Contents

trlcdoc.testrun.RESULTS_FILE = 'sw_test_result_report.trlc'
trlcdoc.testrun.LOG
trlcdoc.testrun.PYTEST_OK_CODES = (0, 1)
trlcdoc.testrun.QUALIFIED_ID = '(?P<id>[A-Za-z_][A-Za-z0-9_]*\\.[A-Za-z_][A-Za-z0-9_]*)'
trlcdoc.testrun.UNITY_OUTPUT
trlcdoc.testrun.MTIME_TOLERANCE = 2.0
trlcdoc.testrun.run_tests(cfg: trlcdoc.config.Config) → bool[source]

Run the tests and create the TRLC test result records.

Parameters:

cfg (Config) – Project configuration with a tests section.

Returns:

True if all tests passed.

Return type:

bool

Raises:

TrlcdocError – If the tests could not be executed.

trlcdoc.testrun.read_junit(junit_file: pathlib.Path, link: dict[str, Any]) → list[tuple[str, bool, list[str]]][source]

Read the test results and link them to their TRLC test cases.

Skipped tests have no result and are not part of the list.

Parameters:
  • junit_file (Path) – JUnit XML file.

  • link (dict[str, Any]) – The tests.link configuration.

Returns:

(test name, passed, qualified test case ids) per test.

Return type:

list[tuple[str, bool, list[str]]]

Raises:
  • TrlcdocError – If a test cannot be linked to a test case, or to several

  • test cases while tests.link.array is not set. –

trlcdoc.testrun.write_results(results: list[tuple[str, bool, list[str]]], trlc_file: pathlib.Path, link: dict[str, Any]) → pathlib.Path[source]

Write the test results as TRLC SwTestCaseResult records.

The records are written into the package of the linked test cases.

Parameters:
  • results (list[tuple[str, bool, list[str]]]) – (test name, passed, qualified test case ids) per test.

  • trlc_file (Path) – TRLC file to write.

  • link (dict[str, Any]) – The tests.link configuration. With ‘array’ the relates component is written as list, otherwise as single reference.

Returns:

The written file.

Return type:

Path

Raises:

TrlcdocError – If the package of the test cases cannot be determined.