Export test results in an augmented JUnit format for usage with Xray ()
Project description
pytest-junit-xray-xml
This plugin for pytest exports test results in an extended JUnit format for consumption by the Xray plugin for Jira.
This plugin aims to also be a drop-in replacement for pytest's built-in JUnit support, so all non-Xray-related functionality will (hopefully soon) be supported.
Rationale
The JUnit support in pytest does not allow for the following features:
- it is not possible to generate
<item>elements as subnodes of a<property>tag (needed for storing test evidence) - it is not possible to store
textin apropertytag
Installation
This package is available on pypi.org
python -m pip install pytest-junit-xray-xml
Usage
[!NOTE] You need to explicitly import all fixtures that you want to use, e.g.
from pytest_junit_xray_xml import record_test_key
To export the results as Xray-compatible JUnit, please start pytest with the parameter --junit-xray-xml <filename.xml>, e.g.
python -m pytest tests/examples.py --junit-xray-xml xray.xml
(All examples are available in tests/examples.py and can be run via the command above)
The following fixtures are supported.
record_test_key
stores the test key in a property named test_key. Xray will attach the test results to the test case identified by this key.
[!ALERT] Only a single test key is supported at the moment
example
def test_record_test_key(record_test_key):
record_test_key("JIRA-1234")
assert True
output
<property name="test_key" value="JIRA-1234" />
record_test_id
stores the test ID in a property named test_id. Xray will attach the test results to the test case identified by this key.
[!ALERT] Only a single test key is supported at the moment
example
def test_record_test_key(record_test_key):
record_test_key("JIRA-1234")
assert True
output
<property name="test_key" value="JIRA-1234" />
record_test_description
stores the (potentially multi-line) test description as the text of a property named test_description. This cannot be accomplished with base pytest fixtures.
example
def test_record_multiple_descriptions(record_test_description):
record_test_description("This is my test description line 1")
record_test_description("and line 2.")
assert True
output
<property name="test_description">This is my test description line 1
and line 2.</property>
record_test_evidence
stores the test evidence with base64 encoding inside the XML. Xray will attach this file to the corresponding Jira ticket.
Multiple files with evidence can be stored for a single test case (not shown in the example below).
example
def test_store_test_evidence(record_test_evidence):
with record_test_evidence("file1.txt", "w", encoding="UTF-8") as f:
f.write("My file content is text")
assert True
output
<property name="testrun_evidence">
<item name="file1.txt">TXkgZmlsZSBjb250ZW50IGlzIHRleHQ=</item>
</property>
example
def test_store_test_evidence_xml(record_test_evidence):
xml_content = ElementTree(Element("my_root", my_attribute="1"))
with record_test_evidence("file1.xml", "wb") as f:
xml_content.write(f)
assert True
output
<property name="testrun_evidence">
<item name="file1.xml">PG15X3Jvb3QgbXlfYXR0cmlidXRlPSIxIiAvPg==</item>
</property>
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pytest_junit_xray_xml-0.2.0.tar.gz.
File metadata
- Download URL: pytest_junit_xray_xml-0.2.0.tar.gz
- Upload date:
- Size: 10.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.0.1 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7d5421cac0ec73280ab2fdb8351d37016158c3f828fb6ccd0566de70462a3816
|
|
| MD5 |
3a3dbb5e7749b0177716a523a494f8ea
|
|
| BLAKE2b-256 |
1f2a6d92f74336e61bab5c9ba676fa1efe4a86ac53b04afb7d3c4cba1d019129
|
Provenance
The following attestation bundles were made for pytest_junit_xray_xml-0.2.0.tar.gz:
Publisher:
publish-to-pypi.yml on PascalVaudrevange/pytest-junit-xray-xml
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pytest_junit_xray_xml-0.2.0.tar.gz -
Subject digest:
7d5421cac0ec73280ab2fdb8351d37016158c3f828fb6ccd0566de70462a3816 - Sigstore transparency entry: 158761650
- Sigstore integration time:
-
Permalink:
PascalVaudrevange/pytest-junit-xray-xml@6e739cbf3dc9473d18e9bafa625e05c54af57967 -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/PascalVaudrevange
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-to-pypi.yml@6e739cbf3dc9473d18e9bafa625e05c54af57967 -
Trigger Event:
release
-
Statement type:
File details
Details for the file pytest_junit_xray_xml-0.2.0-py3-none-any.whl.
File metadata
- Download URL: pytest_junit_xray_xml-0.2.0-py3-none-any.whl
- Upload date:
- Size: 9.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.0.1 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
71522b68c704deb6e314ae36fe85012aae92c69f77688de7e66d92a1fd0e2336
|
|
| MD5 |
2a415172facfc070b1dc3ed8e047246d
|
|
| BLAKE2b-256 |
9d5821a24e2a7ceb2e6b4f535dbe5efeadfa54c9576d095c657f4dff9fdcc4e5
|
Provenance
The following attestation bundles were made for pytest_junit_xray_xml-0.2.0-py3-none-any.whl:
Publisher:
publish-to-pypi.yml on PascalVaudrevange/pytest-junit-xray-xml
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pytest_junit_xray_xml-0.2.0-py3-none-any.whl -
Subject digest:
71522b68c704deb6e314ae36fe85012aae92c69f77688de7e66d92a1fd0e2336 - Sigstore transparency entry: 158761651
- Sigstore integration time:
-
Permalink:
PascalVaudrevange/pytest-junit-xray-xml@6e739cbf3dc9473d18e9bafa625e05c54af57967 -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/PascalVaudrevange
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-to-pypi.yml@6e739cbf3dc9473d18e9bafa625e05c54af57967 -
Trigger Event:
release
-
Statement type: