Skip to content

5. Audit cases behind a Jira Test Run

Continue from 4. Authenticate and publish to Jira/Xray. Use the same xray-demo folder and activated environment.

Use cases.json to investigate the pytest cases behind an aggregate Jira Test Run. Keep the same marked test file. To reproduce only the local observations while debugging an integration result, run:

python -m pytest -q test_example.py --xray-case-report=cases.json

You still get 2 passed. You also get cases.json in xray-demo. The new option tells this plugin where to write its local report. It does not enable Jira uploading.

Open the file in your editor, or pretty-print it:

python -m json.tool cases.json

Here is an excerpt from the report. It shows the actual case names and summaries; we have left out each case's attempts list to keep this first view short:

{
  "schema_version": 1,
  "pytest_exit_status": 0,
  "cases": [
    {
      "nodeid": "test_example.py::test_add_one[one-plus-one]",
      "status": "passed"
    },
    {
      "nodeid": "test_example.py::test_add_one[two-plus-one]",
      "status": "passed"
    }
  ]
}

pytest_exit_status: 0 means the test session succeeded. A nodeid identifies the file, function and input case. Each full case record also has an attempts list, with observed phases:

Phase Meaning
setup Prepare the test and any fixtures.
call Run the test function.
teardown Clean up after the test.

A fixture is pytest code that prepares or cleans up a test resource. Our example has no custom fixtures, but pytest still reports these phases.

cases.json is replaced on each run. Use a different filename to keep an older run. Its parent folder must already exist. This file is the plugin's own format; it is not an Xray import file.