Skip to main content

pytest-Jira-xray-plus

PyPI version snapshot Tested Python versions Licence Tests Documentation build Measured plugin line coverage

Create a separate Jira Xray Generic Test issue for every pytest parameter case, reuse that issue on later runs, and publish each case's independent result into an existing Test Execution. Jira with the Xray app is required for the integration. No comments or native iteration rows substitute for separate Test issues.

Beginner quick start · Offline plan · Create and upload · Troubleshooting

This guide targets 1.0.0. Check PyPI release availability before installing the pinned version. It does not describe 0.1.13. For an unpublished candidate, install its reviewed wheel. Exact-version limitations are recorded in the compatibility document.

Jira/Xray prerequisites

  • Python 3.12+ and pytest 9.1.1–9.x. Use a clean environment; upstream pytest-jira-xray installs the same pytest_xray module and plugin entry point.
  • Jira Server/DC with Xray. Target: Generic Tests on Xray 8.5.3-j10. This exact installed version has not been tested against a live server. Cloud creation, custom Automatic type mapping, native iterations and datasets are unsupported.
  • An authorized project and existing Test Execution. An administrator supplies the Test and Test Execution issue type IDs, Xray Test Type custom field ID, Generic Test Definition field ID, and required creation fields. IDs vary per site.
  • Existing credentials with Browse Projects, Create Issues (only for creation), Edit Issues and Xray import permissions. Project permission checks cannot prove all Xray-specific authorization; an import failure remains a failure.
  • One authoritative durable case map, shared by every creator of this suite. Serialize creators across machines. A local exclusive lock cannot enforce uniqueness across independent map copies or server nodes. Never run independent writers under the same identity namespace.

The offline plan needs no credentials or server and validates no server settings. Only explicit --xray-create-tests permits creating Tests. --jira-xray requests upload; selecting --xray-case-config alone does not grant creation permission. Existing Jira Test specifications are never edited or deleted by this workflow.

1. Create a project

Create xray-demo, open a terminal there, then create a virtual environment:

python -m venv .venv

Activate it with source .venv/bin/activate on Linux/macOS or .venv\Scripts\Activate.ps1 in PowerShell. After 1.0.0 is published:

python -m pip install pytest-jira-xray-plus==1.0.0 pytest-xdist pytest-rerunfailures
python -m pytest --help

During candidate validation install the reviewed wheel instead. Never install both forks in one environment. If both were installed, create a fresh environment.

2. Run two input cases

Save this as test_example.py. Each explicit ID identifies one stable logical case. Keep IDs stable across reruns and change them when the meaning of a case changes. Do not put passwords, personal data or other secrets in IDs.

import pytest

@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
python -m pytest -q

Expect 2 passed. No Jira action occurs. Do not apply a shared xray key marker to these cases. The automatic workflow rejects manual key markers rather than silently combining cases under one Test.

3. Preview the Jira/Xray import

Save this synthetic configuration as case-config.json. Replace the placeholder IDs with administrator-confirmed values before uploading. namespace identifies this suite within the Jira project; keep it stable and unique across repositories.

{
  "project": "DEMO",
  "namespace": "example-suite",
  "test_issue_type": "100",
  "execution_issue_type": "101",
  "test_type_field": "customfield_10",
  "definition_field": "customfield_11",
  "extra_fields": {}
}
python -m pytest -q --xray-case-config=case-config.json --xray-case-plan=plan.json
python -m json.tool plan.json

The plan contains two different SHA-256 identities, two proposed Generic Test creation documents and independent PASS results. It is not an Xray import file: no Jira keys exist yet. Summaries and definitions use opaque identities, not raw parameter values, node IDs or case IDs. Hashing is not encryption; predictable inputs can be guessed. extra_fields is copied as supplied and may be sensitive.

python -m pytest --collect-only -q --xray-case-config=case-config.json --xray-case-plan=collection.json

To identify just one case before looking up its eventual Jira key:

python -m pytest -q -k one-plus-one --xray-case-config=case-config.json --xray-case-plan=singleton.json
python -m json.tool singleton.json

Record the sole cases[0].identity. After the authorized online run below, find that exact identity in case-map.json under cases; its confirmed key is the separate Generic Test issue for this case. The plan itself contains no Jira key.

Collect-only records NOT_RUN without executing tests or using the network. Plans are local output files; use access controls appropriate to their contents.

4. Authenticate and publish to Jira/Xray

Use an existing authorized test project first. Set environment variables through your shell's secure prompt or CI secret store; never commit credentials:

export XRAY_API_BASE_URL=https://jira.example.invalid
read -rsp 'Existing Jira PAT: ' XRAY_API_KEY
export XRAY_API_KEY

The hostname is a placeholder. Keep TLS certificate verification enabled and use trusted certificates. The API key option uses Jira's existing PAT authentication. Basic authentication instead uses XRAY_API_USER and XRAY_API_PASSWORD and omits --api-key-auth; never put secret values on the command line.

After confirming configuration and exclusive writer ownership:

python -m pytest -q --xray-case-config=case-config.json --xray-case-map=case-map.json --jira-xray --api-key-auth --execution=DEMO-1 --xray-create-tests --xray-single-writer

The controller checks project, execution type, permissions and creation metadata; then reuses exact matching Tests or creates missing Tests. It imports each result by its confirmed key into DEMO-1. The execution itself must already exist. Keep case-map.json durable between runs. To reuse only, omit --xray-create-tests and --xray-single-writer. A missing Test then fails closed. The single-writer flag is an explicit operating assertion, not a distributed lock.

Inspect the map locally with python -m json.tool case-map.json. For the synthetic example, the two identities might resolve to DEMO-101 and DEMO-102; actual keys come from Jira and must never be inferred from this example. Temporarily change the second expected value to 99 as shown in section 7, then run use-only:

python -m pytest -q --xray-case-config=case-config.json --xray-case-map=case-map.json --jira-xray --api-key-auth --execution=DEMO-1

Expect pytest exit 1 and two independent Test Runs: the first case's confirmed key has PASS, the second has FAIL. Repeat the same use-only command: both keys remain unchanged and no Test is created. This command imports results online; the repository's installed tutorial verifies it only against a loopback synthetic server. Inspect the selected Test Execution in your authorized environment to check its Test Runs; local fixture success is not live Xray validation.

A lost creation response leaves a pending record. Subsequent runs may reconcile one exact existing Test; zero or multiple matches block further creation. Do not remove the map or its pending entry to force a retry. Have an authorized operator reconcile the outcome and search-index visibility first. No automatic POST retries occur. Import failure may have changed the execution; inspect it before rerunning.

5. Audit independent cases locally

The plan shows one record per selected case without using Jira. For detailed local pytest phases, use the separate audit report and redact identities:

python -m pytest -q --xray-case-report=cases.json --xray-case-redact-identities
python -m json.tool cases.json

This records phase outcomes, retries and worker IDs. Its per-run aliases are not the stable mapping identities. Do not combine this separate audit mode with case creation in the same command; use the plan for the automatic workflow.

6. Choose audit report contents

Raw audit reports expose node IDs, which may contain parameter data. Value capture is separate, explicit and potentially sensitive:

python -m pytest -q --xray-case-report=values.json --xray-case-values

Do not use raw values with private input data. Generation plans never contain raw parameter values automatically. Hook-added evidence and custom fields are your responsibility; they are not automatically redacted.

7. Diagnose a failing case

Temporarily replace the second expected value with 99:

import pytest

@pytest.mark.parametrize('value, expected', [(1, 2), (2, 99)], ids=['one-plus-one', 'two-plus-one'])
def test_add_one(value, expected):
    assert value + 1 == expected
python -m pytest -q --xray-case-config=case-config.json --xray-case-plan=failure.json

Expect exit code 1 and separate PASS/FAIL cases. Successful setup/teardown cannot turn a failure into PASS. Skips are ABORTED; expected failure is FAIL, non-strict unexpected pass is PASS, strict unexpected pass and fixture errors are FAIL. Any failed rerun attempt keeps FAIL. Incomplete collection or a crashed worker withholds all creation/import. Transport or mapping failures produce exit code 3. Restore the passing example before continuing.

import pytest

@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

8. Preserve mapping and recovery evidence

Back up the authoritative case map securely. Each record is pending or confirmed; it is bound to the configured server and fields. Do not copy maps between unrelated servers, change their binding, or assign one Test key to two identities. A crash can leave a .lock file: confirm the owning process stopped and reconcile pending outcomes before manually removing a stale lock. The plugin never breaks locks automatically. Plans are not substitutes for the durable map.

Optional recipes

Parallel tests and retries

python -m pytest -q -n 2 --xray-case-config=case-config.json --xray-case-plan=workers.json
python -m pytest -q -k one-plus-one --xray-case-config=case-config.json --xray-case-plan=selected.json

Workers run tests and report hashed identities. Only the controller locks the map, reads credentials, creates issues and imports results. Different worker collections or incomplete execution block publication. Do not run two independent controllers with separate map copies. Reruns reuse the case identity; a failed attempt remains FAIL.

Associate one function with multiple Tests

Automatic case generation assigns exactly one Test per combination and rejects manual xray markers. Ordinary manual mapping remains available for existing one-to-one cases: @pytest.mark.xray('DEMO-101') with --jira-xray --execution=DEMO-1 (or the complete command python -m pytest --jira-xray --xraypath=results.json for offline export). Never share a key between cases. Multiple distinct manual keys can represent the same ordinary test where intended; this does not enable parameter aggregation. Manual mode does not create Tests.

For a complete offline manual example, temporarily replace test_example.py:

import pytest

@pytest.mark.xray('DEMO-101')
def test_manual():
    assert True
python -m pytest --jira-xray --xraypath=results.json

This writes manual Xray JSON without contacting Jira. --xraypath alone does not enable the publisher. Restore the two-case example for automatic mapping.

Advanced: customize the export with hooks

pytest_xray_results(results, session) runs before import. In automatic mode it may add comments, defects or evidence, but must preserve the execution, ordered Test keys and supported statuses and must not inject testInfo. Comment byte limits still apply. Hooks are trusted local code and can expose sensitive data; no raw failure text is added automatically in this mode. Manual-mode report attachments use the existing report.evidences list of evidence dictionaries.

All package options

Option Purpose and network behavior
--xray-case-config=PATH Select independent automatic Generic Test mapping
--xray-case-plan=PATH Offline plan, mutually exclusive with upload/creation
--xray-case-map=PATH Authoritative durable mapping for online runs
--xray-create-tests Explicit permission to create missing Tests
--xray-single-writer Assert serialized creation with a shared map
--jira-xray Online upload when configured; manual offline export requires --xraypath too
--execution=KEY Existing Test Execution; required in automatic mode
--api-key-auth Existing Jira PAT from the environment
--xray-case-report=PATH Separate offline phase audit
--xray-case-redact-identities Per-run aliases in the audit
--xray-case-values Explicit scalar parameter capture in the audit
--xray-comment-limit=N UTF-8 comment limit, default 32000, minimum 256
--xraypath=PATH Offline manual JSON export, enabled together with --jira-xray
--testplan, --add-captures, --xray-parameter-details, --xray-full-report Manual mapping only
--cloud, --client-secret-auth Existing manual transport only; unsupported for automatic creation

Warning: --jira-xray without an offline output option can publish live results when configured. --xray-case-plan and standalone --xray-case-report are offline; neither grants creation permission.

--allow-duplicate-ids is not an aggregation compatibility mode in 1.0.0. See python -m pytest --help for exact syntax. Options from different workflows must not silently override one another.

Authentication and execution settings

XRAY_API_BASE_URL includes any Jira context path. Existing PAT authentication uses XRAY_API_KEY; Basic uses XRAY_API_USER and XRAY_API_PASSWORD. Automatic creation requires verified TLS; redirects are not followed and HTTP is allowed only for local loopback fixtures. No credentials are needed for plans. No credentials, response bodies or raw case IDs belong in diagnostics.

Result rules and compatibility

Automatic identity hashes a versioned tuple of project, suite namespace, relative logical test path/name and structured parameter identity. For parametrized tests, that structure contains parameter names in pytest insertion order, sorted groups of axis names (names within each group are also sorted), and pytest's ordered per-axis ID components (callspec._idlist). Non-parametrized tests use null. It is not just the displayed joined case ID. Renaming parameters, changing their order within a parametrization, or reordering stacked axes can create new identities and therefore new Tests when creation is authorized. Changing project, namespace, logical test path/name or IDs also changes identity. Keep these inputs stable for the same logical case, with unique IDs for distinct cases.

For example, this test has ordered parameters ['y', 'x'], sorted axes [['x'], ['y']] and ordered ID components ['why', 'ex']:

@pytest.mark.parametrize('x', [1], ids=['ex'])
@pytest.mark.parametrize('y', [2], ids=['why'])
def test_pair(x, y):
    assert x < y

Swapping the two decorators changes the ordered parameters to ['x', 'y'] and ID components to ['ex', 'why'], producing a different identity even though the values and assertion are unchanged. Likewise, changing 'x,y' to 'y,x' in one axis changes identity; reordering rows together with their stable IDs does not. The initial supported automatic subset is static pytest.mark.parametrize with explicit unique string IDs on every axis (including pytest.param(..., id=...) and parametrized fixtures with explicit IDs). Default positional IDs, callable ID generators, dynamic metafunc.parametrize are currently rejected rather than guessed.

Search requires exactly one matching identity label and verifies project, issue type, Generic type and full definition. Missing/moved/modified mapped issues fail; no replacement or overwrite is automatic. Jira search visibility is not a uniqueness constraint. Cross-host concurrency and Xray-specific permissions cannot be proven by this plugin. No live compatibility claim is made for Xray 8.5.3-j10.

Troubleshooting

  • Missing option: check installed version, active interpreter and fork conflict.
  • Metadata rejected: confirm configured numeric issue/field IDs, Generic option, required fields and create screen. Custom Automatic is not assumed Generic.
  • Pending map: reconcile uncertain creation; do not delete the record to retry.
  • Lock exists: stop competing writers and verify ownership before recovery.
  • HTTP/auth/permission/TLS errors: correct the authorized configuration; never disable verification or blindly replay a write.
  • Offline export error: diagnose the destination path. No Jira connection occurs.
  • Test failure: pytest returns 1 even when its result was successfully imported.
  • Partial import or lost response: the execution may have changed. Verify it before deciding whether to rerun; no automatic retry or rollback is implemented.

Project and development

Repository · API decisions · Release readiness. Tests use synthetic fixtures; no workplace server or data. Maintainers run the repository harness, installed-wheel tutorial and independent review before release. Apache-2.0; upstream attribution is retained in NOTICE.

Metadata

Release files for pytest-jira-xray-plus 1.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pytest-jira-xray-plus 1.0.0
File Size Uploaded Provenance Actions
pytest_jira_xray_plus-1.0.0.tar.gz 199.5 kB With provenance Details for pytest_jira_xray_plus-1.0.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for pytest-jira-xray-plus 1.0.0
File Interpreter ABI Platform Actions
pytest_jira_xray_plus-1.0.0-py3-none-any.whl Python 3 none any Details for pytest_jira_xray_plus-1.0.0-py3-none-any.whl

Total release size: 240.9 kB

Release files / pytest_jira_xray_plus-1.0.0.tar.gz

Download URL pytest_jira_xray_plus-1.0.0.tar.gz
Size 199.5 kB
Tags Source
SHA-256 checksum
How to use checksums
c0d9cb3ab4158f5aa7438b3f58f30a252419831b02588db79c540f3f7265afcc
BLAKE2b-256 checksum
How to use checksums
fd34ecbd61a407a2465907461e20a12ee64dc52886dd711f8f1a1268b38246c8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Dec 4, 2026.

Transparency log

Release files / pytest_jira_xray_plus-1.0.0-py3-none-any.whl

Download URL pytest_jira_xray_plus-1.0.0-py3-none-any.whl
Size 41.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
40cf5618b7f254e84680551a0900fae543567d7b63627bc0a9cda3de3fcdf446
BLAKE2b-256 checksum
How to use checksums
c29a49481bf01da8ca1e771df3d19dd81ac30fd2506e05445ae730561c77663f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Dec 4, 2026.

Transparency log

Security for pytest-jira-xray-plus 1.0.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for pytest_jira_xray_plus-1.0.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Dec 4, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page