How do you tell a declarative scenario step from an imperative one?
answer
- Two wordings, same underlying automation
- Look at the nouns, then the verbs
- Would a redesign break the sentence?
- Vague is not the same as declarative
- Mechanics move down, they never vanish
basics
~20 sAn imperative step spells out the interaction: open a page, type a value, press a control. A declarative step names the intent behind it — "a collaborator has editing rights". Declarative steps survive redesigns and stay readable to non-programmers.
solid answer
~50 sLook at the nouns and verbs. Imperative steps use interface nouns — pages, fields, buttons, rows — and mechanical verbs: opens, types, drags, presses. Declarative steps use domain nouns — playlist, collaborator, editing rights — and verbs that name intent: shares, reorders, removes. The practical test is whether the step would need rewriting if the interaction changed while the rule did not; if a new layout breaks the sentence, the sentence was describing the layout. Declarative steps are preferred because the audience for a scenario includes people who cannot read the automation, and because a scenario full of mechanics is unreviewable as a specification. The cost is real: the mechanics do not disappear, they move underneath the step, and someone must keep that translation honest. Imperative wording is legitimate exactly when the interaction *is* the rule — a keyboard-only reordering path, for instance.
code
pseudocode · 6 linesGiven the visitor opens the sign-in page
And the visitor types "nina" into the name field
And the visitor presses the sign-in control
When the visitor clicks the "Late Shift" card in the grid
And the visitor drags row 9 above row 1
Then a confirmation appears in the cornergo deeper
Be able to spot mechanical verbs and interface nouns in a step and rewrite one sentence into intent. Knowing the two labels and being able to convert a click-by-click line is what is expected here.
Explain the change test and the stranger test, and say honestly where the mechanics go once they leave the step text. Interviewers at this level probe whether you understand the cost, not just the preference.
Show judgement on the line between declarative and vague, and be ready to argue for imperative wording where the interaction genuinely is the rule. Bring an example of an over-abstract step that let a defect pass.
Own the standard and how it is upheld — review habits, a shared domain vocabulary, and what you do about an inherited corpus of interface scripts. Be ready to say when the readability payoff does not justify the translation layer at all.
### Two ways to say the same thing Take one rule from a music-streaming service: an editor of a shared playlist may reorder it, and every collaborator sees the new order. Written imperatively, the scenario opens a sign-in page, types a name and a password, presses a control, waits, opens a playlist by clicking a card in a grid, drags row nine to the top, and asserts that a confirmation appears. Written declaratively, it says a shared playlist holds 14 tracks, an editor moves the ninth to first position, and the order starts with that track for every collaborator. The second version has six fewer steps and one important property the first lacks: nothing in it mentions the product's current design. ### How to recognise which one you are reading *Nouns.* Imperative steps name interface parts — page, field, dialog, row, tab, control. Declarative steps name domain concepts — playlist, track, collaborator, editing rights, subscription tier. If you can delete the interface nouns without losing the rule, they were incidental. *Verbs.* Mechanical verbs — opens, clicks, types, drags, scrolls, presses — describe how a human drives a machine. Intent verbs — shares, reorders, removes, invites, revokes — describe what the actor is trying to achieve. The same underlying automation can sit behind either sentence. *The change test.* Would the sentence need editing if the interaction changed but the rule stayed identical? Replace drag-and-drop with a move-to-position menu: the imperative step is now false, the declarative one is untouched. This is the sharpest test, and it is the one worth saying out loud in an interview, because it explains the preference without appealing to taste. *The stranger test.* Hand the scenario to someone who has never used the product. Can they say whether the rule is right? A declarative scenario invites that judgement. An imperative one only lets them confirm that a path was described. ### Why the preference exists A scenario's audience is wider than a unit test's. It is meant to be readable by the people who decide what the product should do, which is the whole reason for the extra translation layer between prose and code. Imperative steps forfeit that benefit while keeping the cost: you now pay for a prose layer that only its author can review. Worse, the rule becomes invisible. A reader of the imperative version cannot tell whether the promise is "collaborators see the new order" or "a confirmation appears" — the assertion drifted to whatever was easiest to observe on screen. There is also a maintenance argument, though it is weaker than it looks. Declarative scenarios survive redesigns; imperative ones are rewritten every time a layout moves. But the mechanics still exist somewhere beneath the step, so a redesign still costs work — it is the *specification* that stops churning, not the automation. ### Where the line actually sits Declarative does not mean vague. "When the listener does the right thing" is not declarative, it is empty: two different behaviours could pass it. A good declarative step is concrete about the domain and silent about the mechanism. "When an editor moves the ninth track to first position" names an exact, checkable event without naming a gesture. Some incidental detail is worth keeping when the rule turns on it. If the rule is about ordering, positions belong in the text. If the rule is about permissions, the actor's role belongs in the text and the positions do not. The judgement is per rule, not global, which is why review matters more than a style rule here. ### When imperative wording is the right answer Three cases come up honestly. First, when the interaction is the subject: a rule about keyboard-only reordering, or about a confirmation step that must be dismissed deliberately, is genuinely about mechanics, and hiding them would hide the rule. Second, in a small number of thin end-to-end paths kept deliberately to prove the assembled system responds at all — but those are better written as ordinary automated checks than as business-facing scenarios. Third, temporarily, while a team is learning the format: a first imperative draft that gets rewritten in review teaches more than a rejected blank page. ### The failure this prevents The damaging version is not merely ugly. In an imperative scenario the assertion tends to slide toward whatever was easiest to see, so the suite ends up proving that the interface reacted rather than that the promise was kept. That is a suite that stays green while the promised behaviour is broken — the specific reason interviewers ask this question rather than treating step wording as a style preference.
- Does making steps declarative reduce the total work, or just move it?Mostly it moves it. The gestures still have to be performed somewhere beneath the step, so a redesign still costs automation work. What declarative wording buys is that the specification stops churning, the same phrasing is reusable across scenarios, and people outside engineering can review the rule. Claiming it makes maintenance free is a red flag; claiming it makes the specification stable is accurate.
- How do you tell an over-abstract step from a properly declarative one?Ask whether two different behaviours could both satisfy the sentence. "When the editor updates the playlist" passes for reordering, renaming and deleting a track, so it specifies nothing. "When the editor moves the ninth track to first position" admits exactly one behaviour while naming no gesture. Concrete about the domain, silent about the mechanism, is the target.
- A rule really is about the interaction — how should the step read then?Name the interaction as the domain concept it is, at the coarsest level that still captures the rule. If the promise is that reordering works without a pointing device, say the editor reorders the playlist using only the keyboard. That keeps the mechanism in the text because the mechanism is the rule, while avoiding key-by-key narration that would break on any change to the shortcuts.
A recipe that says "fold in the egg whites" outlives every kitchen; one that says "press the second button on the mixer" belongs to one appliance.
saying these in an interview costs you the question
- Says declarative just means shorter steps
- Writes vague steps and calls them declarative
- Claims imperative wording is never acceptable
- Believes declarative wording removes the automation work
- Keeps interface nouns because they make the step precise
- Judges wording by style rules instead of the change test