Pytest plugin to generate json report in CTRF (Common Test Report Format)
Project description
CTRF for pytest
Pytest implementation of Common Test Report Format (CTRF) for test results.
Test report will be generated in JSON format.
Test report can be used to prettify the report in GitHub Actions with github-actions-ctrf.
Do not worry if report in GitHub does not appear immediately. It takes some time to process the report.
Features
- Generates JSON report
- Tested to work correctly with and without pytest-xdist
- Tested to get browser name from pytest-playwright
- Parametrized tests are supported and reported as 1 test with multiple retries
Installation
pip install pytest-json-ctrf
Usage
generate report.json file in the root directory of the project. File path is mandatory
pytest --ctrf report.json
Json exampe
More info here: https://ctrf.io/docs/schema/examples
{
"results": {
"tool": {
"name": "jest"
},
"summary": {
"tests": 3,
"passed": 1,
"failed": 1,
"pending": 0,
"skipped": 1,
"other": 0,
"start": 1706644023,
"stop": 1706644043
},
"tests": [
{
"name": "User should be able to login",
"status": "passed",
"duration": 1200
},
{
"name": "User profile information should be correct",
"status": "failed",
"duration": 800
},
{
"name": "User should be able to logout",
"status": "skipped",
"duration": 0
}
]
}
}
Report Example
Technical details
For future me and others who are interested in the technical details of the implementation.
The main idea is to handle xdist plugin because without it collecting report is quite straightforward.
By the example of putest-json-report plugin, I have learned that different plugins can be registered for the controller and workers node.
The pytest_runtest_logreport
hook in the controller node is used to collect the test results from all the nodes so other nodes can just add some details to the TestReport
object.
Credits
- https://ctrf.io/ -> nice data format
- https://github.com/numirias/pytest-json-report -> Source of inspiration and dealing with xdist sync
- https://github.com/testomatio/pytestomatio -> Source of inspiration for creating pytest plugins
- https://github.com/infopulse/Playwright-course-python -> The report will be used in the demo project as +1 report option
Roadmap
- Add screenshots handling
- Add hooks for the report extension
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
File details
Details for the file pytest_json_ctrf-0.2.3.tar.gz
.
File metadata
- Download URL: pytest_json_ctrf-0.2.3.tar.gz
- Upload date:
- Size: 5.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.0.0 CPython/3.12.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6f5993dd111e9071e6ee8bd850d0d7509ad8fcf15bff9b8314f66d5f5acc2585 |
|
MD5 | b6b621fbcfe97acd8bcdad92d4aafd93 |
|
BLAKE2b-256 | 6a888f0ab019fd7accbc0cc7f3742b31aab9bcc52c14ecdd6a20cb5f9f81b2b3 |
File details
Details for the file pytest_json_ctrf-0.2.3-py3-none-any.whl
.
File metadata
- Download URL: pytest_json_ctrf-0.2.3-py3-none-any.whl
- Upload date:
- Size: 6.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.0.0 CPython/3.12.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | bb859ce19f0ea9e3c398b711df4c84a30da40ea0b8a880ca1dbdc7d9b4a3aa59 |
|
MD5 | 52fda882bd67580a57bab1fbe0f1d746 |
|
BLAKE2b-256 | 0c16f2a2cc23681cf337f8e1cd7f6baaafd5e035abaf4a5ea3e29c331a2be2bb |