Name | pytest-junit-xray-xml JSON |
Version |
0.2.0
JSON |
| download |
home_page | None |
Summary | Export test results in an augmented JUnit format for usage with Xray () |
upload_time | 2025-01-01 20:15:38 |
maintainer | None |
docs_url | None |
author | None |
requires_python | >=3.9 |
license | MIT license |
keywords |
xray
pytest
junit
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
# pytest-junit-xray-xml
This plugin for [pytest](https://pytest.org) exports test results in an extended JUnit format for consumption by the [Xray plugin](https://www.getxray.app/)
for [Jira](https://www.atlassian.com/software/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 `text` in a `property` tag
## Installation
This package is available on [pypi.org](https://pypi.org/project/pytest-junit-xray-xml/)
```shell
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.
```shell
python -m pytest tests/examples.py --junit-xray-xml xray.xml
```
(All examples are available in [tests/examples.py](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
```python
def test_record_test_key(record_test_key):
record_test_key("JIRA-1234")
assert True
```
#### output
```xml
<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
```python
def test_record_test_key(record_test_key):
record_test_key("JIRA-1234")
assert True
```
#### output
```xml
<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
```python
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
```xml
<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
```python
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
```xml
<property name="testrun_evidence">
<item name="file1.txt">TXkgZmlsZSBjb250ZW50IGlzIHRleHQ=</item>
</property>
```
#### example
```python
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
```xml
<property name="testrun_evidence">
<item name="file1.xml">PG15X3Jvb3QgbXlfYXR0cmlidXRlPSIxIiAvPg==</item>
</property>
```
Raw data
{
"_id": null,
"home_page": null,
"name": "pytest-junit-xray-xml",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.9",
"maintainer_email": null,
"keywords": "xray, pytest, junit",
"author": null,
"author_email": "Pascal Vaudrevange <pascal@vaudrevange.com>",
"download_url": "https://files.pythonhosted.org/packages/1f/2a/6d92f74336e61bab5c9ba676fa1efe4a86ac53b04afb7d3c4cba1d019129/pytest_junit_xray_xml-0.2.0.tar.gz",
"platform": null,
"description": "# pytest-junit-xray-xml\nThis plugin for [pytest](https://pytest.org) exports test results in an extended JUnit format for consumption by the [Xray plugin](https://www.getxray.app/)\n for [Jira](https://www.atlassian.com/software/jira).\n\nThis 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.\n## Rationale\nThe JUnit support in `pytest` does not allow for the following features:\n- it is not possible to generate `<item>` elements as subnodes of a `<property>` tag (needed for storing test evidence)\n- it is not possible to store `text` in a `property` tag\n\n## Installation\nThis package is available on [pypi.org](https://pypi.org/project/pytest-junit-xray-xml/)\n```shell\npython -m pip install pytest-junit-xray-xml\n```\n\n## Usage\n> [!NOTE]\n> You need to explicitly import all fixtures that you want to use, e.g. `from pytest_junit_xray_xml import record_test_key`\n\nTo export the results as Xray-compatible JUnit, please start pytest with the parameter `--junit-xray-xml <filename.xml>`, e.g.\n```shell\npython -m pytest tests/examples.py --junit-xray-xml xray.xml\n```\n(All examples are available in [tests/examples.py](tests/examples.py) and can be run via the command above)\n\nThe following fixtures are supported.\n\n### record_test_key\nstores the test key in a property named `test_key`. Xray will attach the test results to the test case identified by this key.\n\n> [!ALERT]\n> Only a single test key is supported at the moment\n\n#### example\n```python\ndef test_record_test_key(record_test_key):\n record_test_key(\"JIRA-1234\")\n assert True\n```\n#### output\n```xml\n<property name=\"test_key\" value=\"JIRA-1234\" />\n```\n\n### record_test_id\nstores the test ID in a property named `test_id`. Xray will attach the test results to the test case identified by this key.\n\n> [!ALERT]\n> Only a single test key is supported at the moment\n\n#### example\n```python\ndef test_record_test_key(record_test_key):\n record_test_key(\"JIRA-1234\")\n assert True\n```\n#### output\n```xml\n<property name=\"test_key\" value=\"JIRA-1234\" />\n```\n\n### record_test_description\nstores the (potentially multi-line) test description as the `text` of a property named `test_description`. This cannot be accomplished with base `pytest` fixtures.\n#### example\n```python\ndef test_record_multiple_descriptions(record_test_description):\n record_test_description(\"This is my test description line 1\")\n record_test_description(\"and line 2.\")\n assert True\n```\n#### output\n```xml\n<property name=\"test_description\">This is my test description line 1\nand line 2.</property>\n```\n\n### record_test_evidence\nstores the test evidence with base64 encoding inside the XML. Xray will attach this file to the corresponding Jira ticket.\n\nMultiple files with evidence can be stored for a single test case (not shown in the example below).\n#### example\n```python\ndef test_store_test_evidence(record_test_evidence):\n with record_test_evidence(\"file1.txt\", \"w\", encoding=\"UTF-8\") as f:\n f.write(\"My file content is text\")\n assert True\n```\n#### output\n```xml\n<property name=\"testrun_evidence\">\n <item name=\"file1.txt\">TXkgZmlsZSBjb250ZW50IGlzIHRleHQ=</item>\n </property>\n\n```\n#### example\n```python\ndef test_store_test_evidence_xml(record_test_evidence):\n xml_content = ElementTree(Element(\"my_root\", my_attribute=\"1\"))\n with record_test_evidence(\"file1.xml\", \"wb\") as f:\n xml_content.write(f)\n assert True\n```\n#### output\n```xml\n<property name=\"testrun_evidence\">\n <item name=\"file1.xml\">PG15X3Jvb3QgbXlfYXR0cmlidXRlPSIxIiAvPg==</item>\n</property>\n```\n\n",
"bugtrack_url": null,
"license": "MIT license",
"summary": "Export test results in an augmented JUnit format for usage with Xray ()",
"version": "0.2.0",
"project_urls": {
"Changelog": "https://github.com/PascalVaudrevange/pytest-junit-xray-xml/releases",
"Homepage": "https://github.com/PascalVaudrevange/pytest-junit-xray-xml",
"Issues": "https://github.com/PascalVaudrevange/pytest-junit-xray-xml/issues",
"Repository": "https://github.com/PascalVaudrevange/pytest-junit-xray-xml.git"
},
"split_keywords": [
"xray",
" pytest",
" junit"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "9d5821a24e2a7ceb2e6b4f535dbe5efeadfa54c9576d095c657f4dff9fdcc4e5",
"md5": "2a415172facfc070b1dc3ed8e047246d",
"sha256": "71522b68c704deb6e314ae36fe85012aae92c69f77688de7e66d92a1fd0e2336"
},
"downloads": -1,
"filename": "pytest_junit_xray_xml-0.2.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "2a415172facfc070b1dc3ed8e047246d",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.9",
"size": 9516,
"upload_time": "2025-01-01T20:15:36",
"upload_time_iso_8601": "2025-01-01T20:15:36.126083Z",
"url": "https://files.pythonhosted.org/packages/9d/58/21a24e2a7ceb2e6b4f535dbe5efeadfa54c9576d095c657f4dff9fdcc4e5/pytest_junit_xray_xml-0.2.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "1f2a6d92f74336e61bab5c9ba676fa1efe4a86ac53b04afb7d3c4cba1d019129",
"md5": "3a3dbb5e7749b0177716a523a494f8ea",
"sha256": "7d5421cac0ec73280ab2fdb8351d37016158c3f828fb6ccd0566de70462a3816"
},
"downloads": -1,
"filename": "pytest_junit_xray_xml-0.2.0.tar.gz",
"has_sig": false,
"md5_digest": "3a3dbb5e7749b0177716a523a494f8ea",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.9",
"size": 10564,
"upload_time": "2025-01-01T20:15:38",
"upload_time_iso_8601": "2025-01-01T20:15:38.695857Z",
"url": "https://files.pythonhosted.org/packages/1f/2a/6d92f74336e61bab5c9ba676fa1efe4a86ac53b04afb7d3c4cba1d019129/pytest_junit_xray_xml-0.2.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-01-01 20:15:38",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "PascalVaudrevange",
"github_project": "pytest-junit-xray-xml",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "pytest-junit-xray-xml"
}