Skip to main content

Python script for converting xUnit/JUnit XML format to reStructuredText (.rst) with traceable items

Project description

Apache 2.0 License PyPI packaged release Build status Documentation Code Coverage Requirements Status Contributions welcome

Documentation xunit2rst

This script can convert a JUnit/xUnit (.xml) file to a reStructuredText (.rst) file with traceable items.

Goal

This script allows you to connect your test reports to your test cases via the mlx.traceability Sphinx extension.

Installation

pip3 install mlx.xunit2rst

Usage

mlx.xunit2rst -i itest_report.xml -o my_lib_report.rst --prefix ITEST_MY_LIB-

mlx.xunit2rst --help

usage: mlx.xunit2rst [-h] -i INPUT_FILE -o RST_OUTPUT_FILE [-s] [-p PREFIX]
                     [--trim-suffix]
                     [--unit-or-integration UNIT_OR_INTEGRATION] [-v]

optional arguments:
  -h, --help            show this help message and exit
  -i INPUT_FILE, --input INPUT_FILE
                        The input XML file
  -o RST_OUTPUT_FILE, --output RST_OUTPUT_FILE
                        The output RST file
  -s, --itemize-suites  Flag to itemize testsuite elements instead of testcase
                        elements.
  -p PREFIX, --prefix PREFIX
                        Optional prefix to add to item IDs
  --trim-suffix         If the suffix of the --prefix argument ends with '_-'
                        it gets trimmed to '-'
  --unit-or-integration UNIT_OR_INTEGRATION
                        Optional: give value starting with 'u' or 'i' if the
                        the script's discernment is wrong.
  -v, --version         show program's version number and exit

Behavior

Itemization

By default, all testcase elements from the input file are used to created treaceability items. This may not always be desired. The -s, --itemize-suites flag lets the script itemize testsuite elements instead. In this case, the testcase elements will still be parsed to determine whether the testsuite passed or failed.

Item names

The name attribute of the element to be itemized is used to build the item ID. Lower case letters get converted to upper case, whitespaces get converted to underscores, and & characters get converted to AND. A valid prefix must end with a hyphen to be recognized by the script.

Prefix

Traceability item IDs have a prefix that is unique for the group they belong to, e.g. ITEST_MY_LIB-. The``–prefix`` input argument lets you configure this prefix. It will be prepended to the item names found in the input file to build the item ID. By default, the script adds ITEST- or UTEST- for integration or unit test reports, unless the prefixes already exist in the input file.

Distinction between unit and integration test reports

Test reports that have a testsuites element as root in XML are treated as unit test reports. Otherwise the script treats the input file as an integration test report. This discerning behavior gets overridden when prefixes are found in the input file or the --prefix input argument is used. The script looks for a U or I as the first letter of the prefix. Lastly, you can explicitly define the type by using the --unit-or-integration input argument. Its value should start with u or i and gets parsed case-insensitively.

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

mlx.xunit2rst-0.4.0.tar.gz (21.3 kB view hashes)

Uploaded Source

Built Distribution

mlx.xunit2rst-0.4.0-py2.py3-none-any.whl (12.3 kB view hashes)

Uploaded Python 2 Python 3

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