Skip to main content

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

Example Image

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

Roadmap

  • Add screenshots handling
  • Add hooks for the report extension

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

pytest_json_ctrf-0.3.3.tar.gz (6.7 kB view details)

Uploaded Source

Built Distribution

pytest_json_ctrf-0.3.3-py3-none-any.whl (6.9 kB view details)

Uploaded Python 3

File details

Details for the file pytest_json_ctrf-0.3.3.tar.gz.

File metadata

  • Download URL: pytest_json_ctrf-0.3.3.tar.gz
  • Upload date:
  • Size: 6.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for pytest_json_ctrf-0.3.3.tar.gz
Algorithm Hash digest
SHA256 aff85b46b0d6e398d1b39d9e788872ed06cc1dd95e9faab9b481446733a98cfb
MD5 de6d366858db70876f92637f5eb60271
BLAKE2b-256 b22b1f2daa0c1ff44a43c4a53e4688aaefde7c4f4b659919eee21e5fc711d16a

See more details on using hashes here.

File details

Details for the file pytest_json_ctrf-0.3.3-py3-none-any.whl.

File metadata

File hashes

Hashes for pytest_json_ctrf-0.3.3-py3-none-any.whl
Algorithm Hash digest
SHA256 06c1324e09b6122dd88eca319c0d9d3eb6f85bf900637b4425a333453b8059b0
MD5 d19794ac972af72250c6418626aedfa5
BLAKE2b-256 1c06b06a0b57d38ea13e0da094646ed8be46730b5f1d53f003d2b036495da4b4

See more details on using hashes here.

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