2. Run two input cases¶
Continue from 1. Create a project. Use the same xray-demo folder and activated environment.
Map the example to your Jira Test (DEMO-1 is a placeholder). Create test_example.py inside xray-demo, next to .venv.
Paste this 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
Run it from xray-demo:
Expected summary (timing and progress characters may vary):
Here is how the file works:
import pytestlets us use pytest's test decorators.- The function name starts with
test_, so pytest discovers it. @pytest.mark.xray("DEMO-1")maps both cases to the existing Jira Test.parametrizeruns the function once for each input pair: first1, 2, then2, 3. These two runs are called cases.idsgives those cases readable names. Use names without secrets.assertchecks that adding one gives the expected result.
python -m pytest uses pytest from your active environment. -q keeps output
short. This first command checks the test itself. The Jira marker is in place,
but uploading starts only when --jira-xray is enabled without --xraypath.
Your folder contains:
Pytest may also create cache folders. You do not need to edit them.