3. Preview the Jira/Xray import¶
Continue from 2. Run two input cases. Use the same xray-demo folder and activated environment.
Before importing results, review the Xray payload. Keep the passing test and its Jira Test marker; here is the complete file:
import pytest
@pytest.mark.xray("DEMO-1")
@pytest.mark.parametrize(
"value, expected",
[(1, 2), (2, 3)],
ids=["one-plus-one", "two-plus-one"],
)
def test_add_one(value, expected):
assert value + 1 == expected
The marker, @pytest.mark.xray("DEMO-1"), associates both cases with one Jira
Test issue. DEMO-1 is just a placeholder here; offline export does not look
it up. A Test Execution is the Jira issue that holds a set of test results.
A Test Run is the result of one Test inside that execution.
Generate the Xray preview and a case audit report:
python -m pytest -q test_example.py --xray-case-report=cases.json --jira-xray --xraypath=xray.json --allow-duplicate-ids
| Addition | What it does |
|---|---|
--jira-xray |
Enables export of tests carrying the Xray marker. |
--xraypath=xray.json |
Writes the export to this file instead of sending it. |
--allow-duplicate-ids |
Allows the two cases to share DEMO-1; their Xray results are combined. |
Expected: 2 passed, plus a message showing the generated Xray report file.
You now have two reports with different purposes:
| File | What you will find |
|---|---|
cases.json |
Two separate pytest cases, each passed. |
xray.json |
One Xray result for DEMO-1, with status: "PASS". |
Why one Xray result? Both cases refer to the same Jira Test. This exporter combines them under that key. It does not create native Xray iteration rows.
To keep readable input details in that combined result, add one more option:
python -m pytest -q test_example.py --xray-case-report=cases.json --jira-xray --xraypath=xray.json --allow-duplicate-ids --xray-parameter-details
Open xray.json. Its comment now contains both case names, scalar input
values, the reported phase and its outcome. Open cases.json: it still has two
separate records and still excludes input values by default.
--xray-parameter-details is an explicit opt-in because its comments can contain
sensitive values. It adds details only for parametrized tests. Without it,
passing cases usually have no comment text; failure details can still appear.
Keep --xraypath in every offline export command. Without it, --jira-xray
selects uploading. This also applies when options are inherited from pytest.ini
or PYTEST_ADDOPTS.