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 an AI model, it does not store what you paste, and it is not a verdict on whether the requirement itself is the right requirement. Similar free tools already exist, including gherkin-lint and dod-mcp.
The command output in this article is from a real run of:
npx -y https://acceptpack.onrender.com/acceptpack-lint.tgz file.feature
This article was created with the help of AI. A human chose the examples, ran that command, and checked the output and the advice against the linter's actual rules.
What "testable" means here
A criterion is testable when a reviewer, or a test, can tell pass from fail without asking what we meant. In practice that usually means:
- Every Then names something observable: a message, a status code, a stored record, or a redirect.
- Values are concrete: a quoted string, a number with a unit, an example card, an email.
- Each scenario is self-contained. The Then should not rely on setup that the scenario never states.
- There is one action (one When) per scenario.
- At least one scenario covers failure: a declined card, invalid input, an empty list, a limit.
None of this is a complete method. It is a set of heuristics that catch common gaps.
A weak example, and what the linter said
Here is a scenario that looks finished and is not:
Feature: Checkout
Scenario: Pay for the cart
Given a cart
When the user pays
Then it should work properly
Saved as weak.feature and run with the command above, the linter printed:
acceptpack-lint 0.2.0: 1 scenario(s), 0 error(s), 4 warning(s), 1 info
2:3 warning AP008 no-concrete-value: No concrete value (number, quoted string, status code or Examples table).
hint: Add a specific input and a specific expected value so a test can assert it.
2:3 info AP009 no-negative-path: No scenario covers a failure, invalid input, or edge case.
hint: Add at least one scenario for invalid input, a rejected request, an empty state, or a limit.
5:10 warning AP007 unobservable-then: Then step names no observable outcome.
hint: Say what a reviewer can see or measure: a message, a status code, a stored record, a redirect.
5:13 warning AP006 modal-should: Modal verb 'should/may' states a wish, not a pass/fail result.
hint: Write what happens: "the page shows ..." or "the request returns 403".
5:25 warning AP005 vague-term: Vague term "properly" hides the observable result.
hint: Replace "properly" with the evidence you would accept: a number with a unit, a status code, an exact message, or a state change.
Four of those findings are about the same Then. "Should work properly" is a wish. It has no message, no status, and no record to check. "A cart" and "the user pays" also leave the inputs unspecified, which is why AP008 fires at the scenario.
The same idea, written so a test can check it
We keep the checkout, name the inputs, and say what should be visible and stored. We also add a declined-card scenario, which is what AP009 asked for:
Feature: Checkout
Scenario: Pay for a cart with a valid card
Given the user is signed in as "buyer@x.test"
And the cart has 1 book priced at 19 USD
When the user pays with card "4242 4242 4242 4242"
Then the page shows "Payment received"
And an order with status "paid" is stored
Scenario: Declined card does not create an order
Given the user is signed in as "buyer@x.test"
And the cart has 1 book priced at 19 USD
When the user pays with card "4000 0000 0000 0002"
Then the page shows "Your card was declined"
And no order is stored
Saved as strong.feature and run with the same command, the linter printed:
acceptpack-lint 0.2.0: 2 scenario(s), 0 error(s), 0 warning(s), 0 info
That clean result does not mean the criteria are complete, or that 19 USD and those card numbers are the right product rules. It means this particular linter did not find the gaps it knows how to flag. A reviewer still has to decide whether the behaviour is the behaviour we want.
One action per scenario
A second common gap is two actions in one scenario. This often looks like an And after the first When, but it also appears as a second When:
Feature: Search
Scenario: Find a book
Given the catalog has a book titled "AcceptPack"
When the user types "acceptpack" in the search box
When the user clicks Search
Then the results list shows "AcceptPack"
The same CLI printed:
acceptpack-lint 0.2.0: 1 scenario(s), 0 error(s), 1 warning(s), 1 info
2:3 info AP009 no-negative-path: No scenario covers a failure, invalid input, or edge case.
hint: Add at least one scenario for invalid input, a rejected request, an empty state, or a limit.
5:10 warning AP004 multiple-when: More than one When step in a scenario.
hint: Split into separate scenarios; one action per scenario.
AP004 is asking us to split the work. One scenario can be "submitting the search shows the matching title." A second can be "a search with no matches shows an empty state." The second scenario would also clear AP009.
If the product really has one user action, write one When. "When the user submits a search for 'acceptpack'" is a single action. "When the user types ... When the user clicks ..." is two.
A short checklist we use
Before we hand a feature file to a coding agent, or turn it into tests, we ask:
- Can a reviewer see or measure the Then?
- Are the inputs and expected values written down in this scenario?
- Is there exactly one When?
- Is there a failure, empty, or invalid case?
- Did we avoid words like "properly," "gracefully," or "should," unless a Then still names the evidence?
The linter used above is a shortcut for some of those questions, not a substitute for reading the file.
Try the same check
You can paste a .feature file into the browser linter at https://acceptpack.onrender.com/lint/, or run the CLI we used:
npx -y https://acceptpack.onrender.com/acceptpack-lint.tgz file.feature
It is MIT-licensed, rule-based, and not published to npm. The tarball includes the CLI and an MCP server. There are 15 fixed rules (AP001 to AP015). More about the tool is on https://acceptpack.onrender.com.
This article was created with the help of AI. The commands, the feature files, and the printed output were run and checked by a human.
Top comments (0)