|
1 | 1 | # qase-pytest + pytest-bdd example |
2 | 2 |
|
3 | | -Reproduces the customer feedback scenario: a single Gherkin login |
4 | | -scenario with three steps, each containing a nested manual step via |
5 | | -`qase.step(...)`. |
| 3 | +A runnable demo of the native pytest-bdd integration in qase-pytest. |
| 4 | +Exercises every feature of the integration so you can see how each kind |
| 5 | +of Gherkin construct is reported in Qase. |
6 | 6 |
|
7 | | -## Run |
| 7 | +## What the example covers |
| 8 | + |
| 9 | +| Feature file | Scenario(s) | Demonstrates | |
| 10 | +| --- | --- | --- | |
| 11 | +| `login.feature` | Successful login | Basic Given/When/Then with nested `qase.step()` calls — sub-steps appear as children of the Gherkin step. | |
| 12 | +| `failing.feature` | A failing assertion in the middle step | A failing Then step. The failed step is marked `failed`; pytest-bdd does not run later steps, but the integration records them as `skipped`. | |
| 13 | +| `calculator.feature` | Scenario Outline with 3 example rows | Scenario Outline / Examples — produces three parameterized Qase results for the same scenario. | |
| 14 | +| `data_carriers.feature` | Step with a data table and a docstring | DataTable rendered as a markdown table, DocString rendered as a fenced code block — both end up in the step `data` payload. | |
| 15 | +| `checkout.feature` | Two scenarios sharing a Background | Background steps run before each scenario and are reported on every scenario's result. Multi-scenario feature with distinct `@qase.id=`, `@qase.suite=` tags per scenario. | |
| 16 | + |
| 17 | +## Recognized scenario tags |
| 18 | + |
| 19 | +Tags must be placed on the `Scenario` line (not the `Feature` line) so |
| 20 | +they reach `scenario.tags`: |
| 21 | + |
| 22 | +- `@qase.id=NN` — link to a test case |
| 23 | +- `@qase.suite=A.B.C` — override suite chain (dot for nesting) |
| 24 | +- `@qase.severity=critical` / `@qase.priority=high` / `@qase.layer=e2e` |
| 25 | +- `@qase.ignore` — drop the scenario from the report |
| 26 | +- `@qase.muted` — don't let the scenario fail the run |
| 27 | + |
| 28 | +## Run locally (report mode) |
8 | 29 |
|
9 | 30 | ```bash |
10 | 31 | pip install -r requirements.txt |
11 | 32 | pytest -v |
12 | 33 | ``` |
13 | 34 |
|
14 | | -Inspect the produced JSON under `build/qase-report/results/` — the |
15 | | -result has the scenario name as title, the feature/suite hierarchy from |
16 | | -the tag, three top-level Gherkin steps, and one sub-step under each. |
| 35 | +5 scenarios execute (one failing on purpose). Inspect the produced JSON |
| 36 | +under `build/qase-report/results/`: |
| 37 | + |
| 38 | +- Each result has the scenario name as `title` |
| 39 | +- Each result has a suite chain matching the `@qase.suite` tag |
| 40 | +- Each result has a list of `steps` mirroring the Gherkin steps in order |
| 41 | +- Nested `qase.step(...)` calls (inside step functions) appear as |
| 42 | + children of the corresponding Gherkin step |
| 43 | +- Failed step has `execution.status: "failed"`; trailing unrun steps |
| 44 | + are marked `"skipped"` |
| 45 | +- Scenario Outline produces one Qase result per Examples row |
| 46 | + |
| 47 | +## Run against Qase TestOps |
| 48 | + |
| 49 | +Set `mode` to `testops` in `qase.config.json`, and provide credentials |
| 50 | +via env: |
| 51 | + |
| 52 | +```bash |
| 53 | +export QASE_TESTOPS_API_TOKEN=... |
| 54 | +export QASE_TESTOPS_PROJECT=PROJ_CODE |
| 55 | +pytest -v |
| 56 | +``` |
17 | 57 |
|
18 | | -To send to Qase TestOps instead, set `mode` to `testops` in |
19 | | -`qase.config.json` and provide `QASE_TESTOPS_API_TOKEN` and |
20 | | -`QASE_TESTOPS_PROJECT` via env. |
| 58 | +The TestOps API mode preserves native Gherkin step structure (keyword |
| 59 | ++ name + data) and renders steps with their Given/When/Then keywords |
| 60 | +in the Qase UI. |
0 commit comments