Pytest plugin for generating Xray JSON reports
Project description
pytest-xray-reporter
A pytest plugin that generates Xray JSON reports for test results.
Installation
pip install pytest-xray-reporter
Usage
The plugin can be used with pytest to generate Xray JSON reports. It supports various command line options to configure the report generation.
Basic Usage
pytest --xray-output=xray-report.json
Command Line Options
--xray-output: Output file for Xray JSON report (default: "xray-report.json")--xray-project: Xray project key--xray-test-plan: Xray test plan key--xray-test-execution: Xray test execution key--xray-test-key: Xray test key to use for all tests (if not provided, uses test function name and logs a warning)
Example
# Using a specific test key
pytest --xray-output=xray-report.json \
--xray-project=PROJ \
--xray-test-plan=PROJ-123 \
--xray-test-execution=PROJ-456 \
--xray-test-key=PROJ-789
# Using test function names as test keys (will show a warning)
pytest --xray-output=xray-report.json \
--xray-project=PROJ \
--xray-test-plan=PROJ-123 \
--xray-test-execution=PROJ-456
Report Format
The plugin generates a JSON report in the following format:
{
"tests": [
{
"testKey": "PROJ-789", // Or test function name if --xray-test-key is not provided
"start": "2024-03-21T10:00:00+00:00",
"finish": "2024-03-21T10:00:01+00:00",
"status": "PASSED",
"comment": "",
"evidence": [
{
"data": "base64_encoded_data",
"filename": "stdout.txt",
"contentType": "text/plain"
}
],
"customFields": [
{
"id": "test_path",
"name": "Test Path",
"value": "test_file.py::test_function"
}
]
}
],
"info": {
"summary": {
"total": 1,
"passed": 1,
"failed": 0,
"errors": 0,
"skipped": 0,
"duration": 1.0
},
"testEnvironments": [
"Linux",
"5.4.0",
"Python 3.9.0"
],
"project": "PROJ",
"testPlanKey": "PROJ-123",
"testExecutionKey": "PROJ-456"
}
}
Features
- Generates Xray-compatible JSON reports
- Captures test output (stdout, stderr)
- Includes test duration
- Supports test execution keys
- Supports test plan keys
- Supports project keys
- Supports custom test keys (optional, falls back to test function name with warning)
- Captures test evidence (output, logs, stack traces)
- Includes test environment information
- Supports custom fields from pytest markers
Test Status Mapping
The plugin maps pytest outcomes to Xray statuses:
passed→PASSEDfailed→FAILEDerror→ERRORskipped→SKIPPED- Other outcomes →
UNKNOWN
Custom Fields
The plugin automatically includes the following custom fields:
test_path: The full path to the test function- Any pytest markers with values (except internal pytest markers)
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
License
This project is licensed under the MIT License - see the LICENSE file for details.
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 Distributions
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_xray_reporter-0.1.18-py3-none-any.whl.
File metadata
- Download URL: pytest_xray_reporter-0.1.18-py3-none-any.whl
- Upload date:
- Size: 7.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
13d21090e5b569563863b7e7afcbb4195d141a19d1711f11903f940346a036b7
|
|
| MD5 |
46d884b8e09b01273f211fa6c912361d
|
|
| BLAKE2b-256 |
cb825d52833be67ca6325e12d62891249b906e6b2aae7d2ebff2241f918e9dd5
|
Provenance
The following attestation bundles were made for pytest_xray_reporter-0.1.18-py3-none-any.whl:
Publisher:
publish.yml on kitlabcode/pytest-xray-reporter
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pytest_xray_reporter-0.1.18-py3-none-any.whl -
Subject digest:
13d21090e5b569563863b7e7afcbb4195d141a19d1711f11903f940346a036b7 - Sigstore transparency entry: 216871191
- Sigstore integration time:
-
Permalink:
kitlabcode/pytest-xray-reporter@9e33d4dc2daf72d143e730c9c13bc406f5aac9b4 -
Branch / Tag:
refs/tags/v0.1.18 - Owner: https://github.com/kitlabcode
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@9e33d4dc2daf72d143e730c9c13bc406f5aac9b4 -
Trigger Event:
release
-
Statement type: