Urgent.News

What's breaking now, across hundreds of outlets.

Tech

Write Given/When/Then criteria a test can actually check

Coding agents, and the tests we later write, only see what we put on the page. If a Then says the payment "should work properly," there is nothing for a test to assert and nothing for an agent to build against. It has to invent a meaning. This article is about making Given/When/Then (Gherkin) criteria testable. The checks below are from a free, rule-based linter called acceptpack-lint. It is not…

Testing criteria for Given/When/Then criteria in Gherkin can be determined by ensuring the following points:

- Every Then statement must describe an observable outcome, such as a message, status code, stored record, or redirect.

- The values mentioned should be concrete, such as specific strings, numbers with units, or examples.

- Each scenario should be self-contained and not rely on any setup that is not described within the scenario itself.

- There should only be one action per scenario, represented by a single When step.

- At least one scenario should cover a failure case, such as a declined card, invalid input, an empty list, or a limit.

- The use of modal verbs like "should" or "may" should be replaced with specific outcomes that can be measured, like "the page shows" or "the request returns."

- Avoid vague terms and replace them with evidence that can be checked, like numbers, status codes, messages, or state changes.

These guidelines serve as a set of heuristics to identify common gaps in test criteria. However, it is important to note that they are not a complete method and still require human review to determine if the behavior meets the desired requirements.

Rewritten by urgent.news; may contain errors — check the original.

Source: dev.to

Read the original at dev.to →

Report a problem with this story

More in Tech

More from Saturday, 28 November 2026 →