Scenario locators
A requirement can list its acceptance criteria as scenarios in a fenced
feature block. A test can then say which scenario it verifies, by adding the
scenario name in square brackets after the requirement ID. This is a locator.
markspec check tests that the locator names a real scenario, and
markspec report coverage shows which scenarios have a verifier.
To write the scenarios, see Gherkin scenarios.
Address a scenario
Add the scenario name in brackets after the target of a Verifies: value. The
test below verifies the first scenario of the requirement. The requirement has
two scenarios.
- [REQ_BRK_0010] Emergency braking for close obstacles
The braking controller shall start braking when an obstacle is detected
closer than 40 m at speeds of 60 km/h or less.
```feature
Scenario: Brake at 20 m
When an obstacle appears at 20 m
Then braking starts within 200 ms
Scenario: No braking beyond 40 m
When an obstacle appears at 50 m
Then the controller does not brake
```
- [TST_BRK_0012] Brake reaction at 20 m
Place the target at 20 m and measure the brake reaction.
Verifies: REQ_BRK_0010 [Brake at 20 m]
Run markspec fmt to stamp the Id: lines.
The profile must map the prefixes to core types: REQ_ to Requirement and
TST_ to Test. Verifies is a core relation, so the test type does not need to
declare it.
The locator has these properties:
- The
[must follow whitespace after the ID. - Case and spelling must match the scenario name. Runs of whitespace count as one space.
- A name can contain commas. A literal
]is written\]. Verifies:andSatisfies:accept scenario locators.References:andDerived-from:accept free-text locators such as[§4.3]that are not checked. Other relations do not accept a locator.- A
Verifies:value without a locator verifies every scenario of the requirement. A value without a closed locator is read as it was before locators existed. - Only scenarios in top-level
featureblocks are indexed for locators. A block nested in a list item yields no scenarios for them. The role checks (see Role of a Gherkin block) andMSL-B062do check blocks nested in list items, at any depth. A block in a block quote is not walked: it gets no locators, no role check and noMSL-B062. - A locator never changes the link: the link goes to the requirement whether the locator resolves or not.
See Locators for the full grammar.
Diagnostics
| Code | Severity | Cause |
|---|---|---|
MSL-L007 | warning | The locator names no addressable scenario of its target. |
MSL-L008 | warning | The relation does not accept a locator. The link to the target is kept. |
MSL-L009 | warning | A value has a [ that no ] closes. Commas after the [ still separate values. |
MSL-B060 | warning | A scenario name is used more than once in one entry. A locator cannot address that name. |
MSL-B061 | info | A scenario has an empty name. A locator cannot address it. |
MSL-B062 | warning | A Gherkin block does not parse. The warning names the line of the first error. |
MSL-B063 | warning | A step of a procedure has actions and no expected result (Test entries). |
MSL-B064 | warning | A scenario of a Requirement or Contract entry has no Then step. |
MSL-B065 | info | A step of a procedure has an expected result and no action (Test entries). |
MSL-B066 | info | A scenario of a Requirement, Contract or Test entry starts with And or But. |
MSL-B067 | info | A # Step label in a Test entry labels no step. |
MSL-B068 | info | A feature block is in a typed entry that is not a Requirement, Contract or Test. |
If a second test in the example verifies [Brake at 30 m], a scenario that does
not exist, markspec check reports:
warning[MSL-L007]: docs/braking.md:30 TST_BRK_0013: locator 'Brake at 30 m' matches no scenario of REQ_BRK_0010
Coverage
markspec report coverage adds a criteria section for each requirement that has
scenarios. With the example above, it shows:
## Criteria
```text
REQ_BRK_0010 Emergency braking for close obstacles 1/2 criteria verified
✓ Brake at 20 m ← TST_BRK_0012
✗ No braking beyond 40 m ← no verifier
```
A scenario with no verifier is a gap in the report. It does not raise a
diagnostic. Only Verifies: from a test counts (an entry whose type is, or
extends, Test); a Satisfies: locator does not, and an entry never verifies
itself. The json format carries the same data; csv carries only the
Criteria total and Criteria verified counts. See the
CLI reference for the counting rules.