Run End-to-End Tests from Your Terminal with Kane CLI

Author and Run Tests Right from the Terminal in Natural Language, with an Evidence-Backed Pass or Fail from a Real Browser.

npm install -g @testmuai/kane-cli

EARS Requirements Notation: Patterns, Examples and How to Test Each One

EARS notation in plain words: the five requirement patterns, examples, how Kiro uses EARS, and the exact test assertion each pattern turns into.

Summarise with AI

EARS (Easy Approach to Requirements Syntax) is a way of writing requirements with a small set of sentence templates, most starting with a keyword such as WHEN, WHILE, IF or WHERE, followed by "the system shall" and a response. It was introduced in 2009 by Alistair Mavin and colleagues at Rolls-Royce to make natural-language requirements less ambiguous.

This guide from TestMu AI (formerly LambdaTest) covers the five patterns, how Kiro uses EARS, the mistakes that make requirements untestable, and the test assertion each pattern turns into.

TL;DR

EARS notation (Easy Approach to Requirements Syntax) is a set of sentence templates for writing requirements. Every requirement keeps one clause order: an optional WHILE state, an optional WHEN trigger, the system name, shall, and the system response, which is the part a test checks.

What Are the 5 EARS Patterns?

  • Ubiquitous: An EARS requirement with no keyword that is always active, such as "The checkout page shall display prices in the store's currency." It suits units, formats and limits that hold everywhere.
  • Event-driven: An EARS requirement that starts with WHEN and states the response to a trigger, such as a user applying a discount code and the checkout page showing the new total.
  • State-driven: An EARS requirement that starts with WHILE and applies for as long as a state is true, such as an empty cart keeping the Pay button disabled.
  • Unwanted behaviour: An EARS requirement written with IF and THEN that states the response to an undesired situation, such as a declined card producing a "Payment declined" message.
  • Optional feature: An EARS requirement that starts with WHERE and applies only in products that include a feature, such as a store with gift wrapping enabled showing a gift-wrap option.

Can EARS Requirements Be Tested Automatically?

Yes, when the response after shall names something a test can observe: an exact message, a value, a page or a control state. The precondition becomes setup, the trigger becomes the action, and the response becomes the assertion. Kane CLI by TestMu AI designs browser tests from a requirements file and records a gap when a promise has no stated expected result.

What Is EARS Notation?

EARS notation is a lightweight syntax for natural-language requirements. Every requirement follows one ordered template: optional state (WHILE), optional trigger (WHEN), the system name, SHALL, and the system response. Five patterns cover most requirements. EARS needs no tool, so teams write it in Word, Jira, Markdown or a spec file.

EARS was published as "Easy Approach to Requirements Syntax (EARS)" by Alistair Mavin, Philip Wilkinson, Adrian Harwood and Mark Novak at RE'09, the 17th IEEE International Requirements Engineering Conference, Atlanta, 2009, pages 317-322 (University of Manchester record).

The authors developed it while analysing airworthiness regulations for a jet-engine control system (Alistair Mavin's EARS page).

The generic EARS template is:

WHILE <optional precondition>, WHEN <optional trigger>, the <system name> SHALL <system response>

Each clause has one job. The precondition says when the requirement applies. The trigger says what starts it. The response says what must be observable afterwards. That last clause is the part a test checks.

What Are the Five EARS Patterns?

The five EARS patterns are ubiquitous, event-driven, state-driven, unwanted behaviour and optional feature. Each adds one keyword to the base "the system shall" sentence: none, WHEN, WHILE, IF ... THEN, or WHERE. Complex requirements combine keywords, such as WHILE plus WHEN, when behaviour needs both a state and a trigger.

PatternKeywordTemplateExample (web checkout)
UbiquitousnoneThe <system> shall <response>The checkout page shall display prices in the store's currency.
Event-drivenWHENWHEN <trigger>, the <system> shall <response>WHEN the user applies code SAVE10 to a 50.00 cart, the checkout page shall show a total of 45.00.
State-drivenWHILEWHILE <precondition>, the <system> shall <response>WHILE the cart is empty, the checkout page shall disable the Pay button.
Unwanted behaviourIF ... THENIF <trigger>, THEN the <system> shall <response>IF the payment provider declines the card, THEN the checkout page shall show "Payment declined" and keep the cart unchanged.
Optional featureWHEREWHERE <feature is included>, the <system> shall <response>WHERE gift wrapping is enabled for the store, the checkout page shall show a gift-wrap option.
ComplexcombinationsWHILE <state>, WHEN <trigger>, the <system> shall <response>WHILE the user is signed out, WHEN they select Pay, the checkout page shall redirect to sign-in.

Templates follow the patterns described in the original paper (Mavin et al., 2009). Examples are ours.

When to use each:

  • Ubiquitous - properties that hold everywhere, such as units, formats and limits. If it only applies after an action, it is really event-driven.EARS ubiquitous requirement split into system and response, mapped to test setup and assertion
  • Event-driven (WHEN) - most feature behaviour. The trigger must be something a test can cause.EARS event-driven requirement split into trigger, system and response, mapped to test action and assertion
  • State-driven (WHILE) - behaviour that lasts as long as a state does. Test it during the state and after it ends.EARS state-driven requirement split into precondition, system and response, mapped to test setup and assertion
  • Unwanted behaviour (IF ... THEN) - errors and misuse. These are the requirements most often missing an expected result.EARS unwanted behaviour requirement split into trigger, system and response, mapped to test action and assertion
  • Optional feature (WHERE) - product variants or configuration. Each WHERE is a test configuration: one run with it on, one with it off.EARS optional feature requirement split into precondition, system and response, mapped to test setup and assertion
  • Complex - behaviour that needs both a state and a trigger.EARS complex requirement split into precondition, trigger, system and response, mapped to test setup, action and assertion

How Does Kiro Use EARS in requirements.md?

Kiro writes the requirements file of each spec in EARS.

Its docs describe requirements.md as capturing "system behaviors in EARS format (WHEN...THE SYSTEM SHALL...)" and call EARS requirements "unambiguous and testable" and "easy to translate into test cases" (Kiro docs).

Kiro then extracts properties from those requirements for property-based tests. As of Nov 2026, Kiro's requirements-first docs show examples like:

WHEN a user submits valid registration data
THE SYSTEM SHALL create a new user account

WHEN a user submits an email that already exists
THE SYSTEM SHALL display "Email already registered" error

Kiro's form is EARS event-driven, with "THE SYSTEM" as the system name and the line break in place of the comma.

Kiro's correctness feature "extracts properties from your EARS-formatted requirements" and runs generated property-based tests (Kiro correctness docs). Proving that a property holds for every input, rather than for generated samples, is the job of formal verification.

Specs live in your repo under .kiro/specs/, one folder per feature (Kiro best practices).

The example gets one thing right and leaves one open. "Display 'Email already registered' error" names an exact message, so a test can check it. "Create a new user account" does not say what the user sees, so a browser test has to decide what proves it. That gap is the subject of the next section.

Writing the spec before the code is the approach covered in spec driven development, and Kiro is compared with other spec toolkits in spec-driven development tools.

How Do You Turn an EARS Requirement Into a Test?

Each EARS clause maps to one part of a test. The precondition (WHILE, WHERE) becomes setup. The trigger (WHEN, IF) becomes the action. The response after SHALL becomes the assertion, which is the test oracle. If the response names no observable value, state or message, the requirement has no oracle and cannot be tested yet.

This is the table we use. The assertions are written as Kane CLI _test.md assert steps, where @verifies names the acceptance criterion each assert proves (Kane CLI design docs).

EARS patternWhat the test sets upTest oracle (what decides pass/fail)Example assertion
UbiquitousAny normal state, ideally several pagesThe property holds on every page or response checked## Step 3 - assert @verifies ac-1 · Every price on the checkout page shows the € symbol
Event-driven (WHEN)Preconditions for the trigger (a 50.00 cart)The response appears after the trigger, and not before## Step 4 - assert @verifies ac-2 · After applying SAVE10, the order total reads 45.00
State-driven (WHILE)Enter the state (empty cart), then leave itResponse holds during the state and ends after it## Step 2 - assert @verifies ac-3 · With an empty cart, the Pay button is disabled; after adding an item it is enabled
Unwanted behaviour (IF/THEN)Force the fault (a test card that always declines)The error response appears and nothing else changes## Step 5 - assert @verifies ac-4 · The page shows Payment declined and the cart still has 2 items
Optional feature (WHERE)Two configurations: feature on and offResponse present only when the feature is on## Step 3 - assert @verifies ac-5 · With gift wrapping enabled, a Gift wrap checkbox is visible (run a second test with it disabled)
Complex (WHILE + WHEN)Enter the state, then cause the triggerResponse happens only in that state## Step 3 - assert @verifies ac-6 · Signed out, selecting Pay lands on /sign-in

Two rules come out of this table:

  • Every SHALL needs something to look at. A message in quotes, a number, a URL, an enabled or disabled control, a record that exists. If you cannot write the assertion column, rewrite the requirement.
  • State and optional patterns need two checks. One where the condition holds and one where it doesn't. Otherwise a test passes on a system that shows the response all the time.

Kane CLI enforces the first rule. When kane-cli design tests finds a promise with no stated expected result, it records a missing-expected-result gap with a recommended default instead of inventing an answer (design docs). You decide the answer. See the whole loop in spec-driven testing.

For features with no single expected output, such as AI-generated text, the test oracle problem covers the checks that replace an exact assertion. An EARS line plays the part of an acceptance criterion; acceptance criteria vs acceptance tests covers where one ends and the other starts. For a business flow, see the Oracle procure to pay test cases, where each ends in one expected result, such as a named invoice hold.

What Are Common EARS Mistakes That Make Requirements Untestable?

The most common EARS mistakes are a response with no observable result, vague words such as "fast" or "appropriate", two behaviours in one SHALL, IF without THEN, and triggers a test cannot cause. Each one passes a format check and still leaves a tester guessing what "pass" means.

MistakeWritten asRewritten as
No observable responseWHEN the user signs up, the system shall create an account.WHEN the user submits valid signup data, the system shall show the "Welcome" page and send a confirmation email to that address.
Vague wordWHEN search runs, the system shall return results quickly.WHEN the user submits a search, the system shall show results within 2 seconds.
Two behaviours in oneWHEN an order is placed, the system shall charge the card and email a receipt.Split into two requirements, one per SHALL.
IF without THENIF the session expires the system shall log the user out.IF the session expires, THEN the system shall redirect to sign-in and show "Your session expired".
Untestable triggerWHEN the server is under heavy load, ...WHEN more than 500 requests per second arrive, ... (and test it with a load tool, not a browser test)
Implementation, not behaviourThe system shall use Redis to cache carts.WHEN the user returns within 7 days, the system shall restore their cart.
Missing system nameWHEN Pay is selected, shall show confirmation.WHEN the user selects Pay, the checkout page shall show the order confirmation.
"Should" instead of SHALLThe system should validate the email.IF the email has no @, THEN the signup form shall show "Enter a valid email".

Want to check a spec quickly? The spec testability checker tags EARS patterns and flags lines with no expected result, in your browser.

A Node.js Script That Flags Untestable EARS Lines

For a check that can run in CI, a dependency-free Node.js script written for this guide reads a requirements file line by line. It tags each line's EARS pattern from its keywords and flags six of the mistakes above: no observable response, a vague word, two behaviours in one SHALL, IF without THEN, a missing system name and "should" instead of SHALL.

// ears-lint.mjs: tags the EARS pattern of each
// requirement and flags wording that leaves a test
// without an oracle.
// Usage: node ears-lint.mjs requirements.md
import { readFileSync } from 'node:fs';

const KEYS = ['where', 'while', 'when', 'if'];
const NAMES = { where: 'Optional', while: 'State-driven',
  when: 'Event-driven', if: 'Unwanted' };
const VAGUE = ['quickly', 'fast', 'easy', 'appropriate',
  'appropriately', 'user-friendly', 'efficiently'];
const SEEN = ['show', 'display', 'disable', 'enable',
  'redirect', 'send', 'hide', 'keep', 'update',
  'return', 'email', 'log'];
const EFFECTS = ['charge', 'email', 'send', 'create'];

function check(text) {
  const t = text.toLowerCase();
  const at = t.indexOf(' shall ');
  if (at < 0) {
    const alt = ['should', 'must', 'will']
      .find((w) => t.includes(' ' + w + ' '));
    const note = alt ? ' (found "' + alt + '")' : '';
    return { name: 'none', flags: ['no "shall"' + note] };
  }
  const clauses = t.slice(0, at).split(',')
    .map((c) => c.trim());
  const keys = clauses.map((c) => c.split(' ')[0])
    .filter((w) => KEYS.includes(w));
  const name = keys.length === 0 ? 'Ubiquitous'
    : keys.length > 1 ? 'Complex' : NAMES[keys[0]];
  const flags = [];
  const subject = clauses.at(-1).replace(/^then /, '');
  if (keys.includes('if') &&
      !clauses.some((c) => c.startsWith('then '))) {
    flags.push('IF without THEN');
  } else if (!subject ||
      KEYS.includes(subject.split(' ')[0])) {
    flags.push('no system name before shall');
  }
  const response = t.slice(at + 7);
  const words = response.split(' ')
    .map((w) => w.replace('.', ''));
  const effects = words.filter((w) => EFFECTS.includes(w));
  if (effects.length > 1) {
    flags.push('two behaviours in one shall');
  }
  const vague = words.find((w) => VAGUE.includes(w));
  if (vague) flags.push('vague word "' + vague + '"');
  const visible = /["0-9/]/.test(response) ||
    words.some((w) => SEEN.includes(w));
  if (!visible) flags.push('no observable result');
  return { name, flags };
}

const file = process.argv[2] || 'requirements.md';
const reqs = readFileSync(file, 'utf8').split('\n')
  .map((l) => l.trim())
  .filter((l) => l.startsWith('- REQ-'));
console.log('Input: ' + file + ', ' + reqs.length +
  ' requirements');
console.log('');
let flagged = 0;
for (const line of reqs) {
  const cut = line.indexOf(':');
  const id = line.slice(2, cut);
  const req = line.slice(cut + 1).trim();
  const { name, flags } = check(req);
  if (flags.length) flagged++;
  const verdict = flags.length
    ? 'FLAG ' + flags.join('; ') : 'ok';
  console.log(id.padEnd(7) + name.padEnd(13) + verdict);
}
console.log('');
const ok = reqs.length - flagged;
console.log('Summary: ' + reqs.length + ' checked, ' +
  ok + ' ok, ' + flagged + ' flagged');
process.exitCode = flagged ? 1 : 0;

The input, requirements.md, holds the six pattern examples from this guide as REQ-01 to REQ-06 and the six matching mistakes as REQ-07 to REQ-12:

## Checkout requirements

- REQ-01: The checkout page shall display prices in the store's currency.
- REQ-02: WHEN the user applies code SAVE10 to a 50.00 cart, the checkout page shall show a total of 45.00.
- REQ-03: WHILE the cart is empty, the checkout page shall disable the Pay button.
- REQ-04: IF the payment provider declines the card, THEN the checkout page shall show "Payment declined" and keep the cart unchanged.
- REQ-05: WHERE gift wrapping is enabled for the store, the checkout page shall show a gift-wrap option.
- REQ-06: WHILE the user is signed out, WHEN they select Pay, the checkout page shall redirect to sign-in.
- REQ-07: WHEN the user signs up, the system shall create an account.
- REQ-08: WHEN search runs, the system shall return results quickly.
- REQ-09: WHEN an order is placed, the system shall charge the card and email a receipt.
- REQ-10: IF the session expires the system shall log the user out.
- REQ-11: WHEN Pay is selected, shall show confirmation.
- REQ-12: The system should validate the email.

Run node ears-lint.mjs requirements.md and the script prints:

Input: requirements.md, 12 requirements

REQ-01 Ubiquitous   ok
REQ-02 Event-driven ok
REQ-03 State-driven ok
REQ-04 Unwanted     ok
REQ-05 Optional     ok
REQ-06 Complex      ok
REQ-07 Event-driven FLAG no observable result
REQ-08 Event-driven FLAG vague word "quickly"
REQ-09 Event-driven FLAG two behaviours in one shall
REQ-10 Unwanted     FLAG IF without THEN
REQ-11 Event-driven FLAG no system name before shall
REQ-12 none         FLAG no "shall" (found "should")

Summary: 12 checked, 6 ok, 6 flagged
  • REQ-07 - "create an account" names no message, value, page or control, the same gap as the "create a new user account" line in Kiro's example.
  • REQ-08 - "return" counts as observable, but "quickly" gives the assertion no number to compare against.
  • REQ-10 - without THEN or a comma, neither the script nor a reader can tell where the trigger ends and the system name starts.
  • Exit code - the script sets exit code 1 when any line is flagged, so a CI job can fail on it.

The script reads keywords and two short word lists, so it can flag a line for the wrong reason or pass a line a reviewer would reject; add your own product's verbs to the observable list. It reads only lines that start with "- REQ-" and expects a comma before the system name, so join Kiro's two-line WHEN and THE SYSTEM SHALL format onto one line first. It is a standalone illustration, not a TestMu AI product.

Note

Note: Kane CLI by TestMu AI runs the checks you derive from EARS requirements in a real Chrome browser and seals the evidence of every run. To try it, start free.

What Is the Difference Between EARS and Gherkin?

EARS and Gherkin solve different problems. EARS states a requirement as a single rule ("WHEN X, the system shall Y"). Gherkin describes a concrete example of that rule as a scenario ("Given ... When ... Then ..."). EARS suits requirement documents; Gherkin suits executable examples. Many teams write the rule in EARS and one or more Gherkin scenarios underneath.

AspectEARSGherkin
UnitOne requirementOne example scenario
ShapeWHEN <trigger>, the <system> shall <response>Given <context> When <action> Then <outcome>
ValuesGeneral ("a valid code")Concrete ("SAVE10", "45.00")
Typical homeSRS, Kiro requirements.md, regulated specs.feature files, Spec Kit acceptance scenarios
ExecutableNo, it needs a test derived from itYes, with step definitions
Negative pathsExplicit IF ... THEN patternWritten as separate scenarios

The same rule in both:

EARS:
WHEN the user applies a valid discount code, the checkout page shall show the discounted total.

Gherkin:
Scenario: Apply SAVE10 to a 50.00 cart
  Given a cart totalling 50.00
  When the user applies code "SAVE10"
  Then the order total shows "45.00"

The EARS line tells you a test is needed. The Gherkin scenario tells you which values to test with. For more on scenario-style criteria, see acceptance criteria examples and Gherkin testing.

Where Should EARS Sit in a Requirements Document?

EARS works best in the functional requirements section of a software requirements specification, one requirement per line, each with an ID. Keep context, goals and user stories in prose above it, and put acceptance examples below. IDs matter because tests and traceability matrices point at them.

A practical layout:

## Functional requirements
- REQ-CART-01: WHEN the user applies a valid discount code, the checkout page shall show the discounted total.
- REQ-CART-02: IF the code has expired, THEN the checkout page shall show "This code has expired".
- REQ-CART-03: WHILE the cart is empty, the checkout page shall disable the Pay button.

Those IDs are what a requirements traceability matrix links tests to. For the wider document structure, see how to write software requirement specifications.

When Should You Not Use EARS?

Skip EARS when one sentence cannot hold the behaviour. EARS allows many preconditions, but a line with three or four of them hides a set of input combinations that one assertion cannot cover.

  • Many interacting conditions - write the rule as a decision table, where each rule in the table becomes one test.
  • Long sequences of states - an order moving from placed to paid, shipped and refunded reads better as a state diagram, and state transition testing derives the tests from it.
  • Formulas and calculations - a tax or pricing rule needs the formula itself, so keep it in a table or an equation and let one EARS line point to it.

Test Your EARS Requirements Against the Real App

Writing requirements in EARS makes the oracle visible. Kane CLI from TestMu AI reads the requirements file, asks you about missing expected results, designs one test per scenario with @verifies tags, and runs it in a real browser.

npm install -g @testmuai/kane-cli
kane-cli login
kane-cli context ingest requirements.md --as checkout-req
Kane CLI - Testing Agent in Your Terminal

Kane CLI Steps From Ingest to Report

  • Ingest - kane-cli context ingest requirements.md --as checkout-req saves a snapshot of the file, identified by a hash of its bytes, in a local .context/ store, and on a terminal continues into a chat where an AI agent extracts use-cases from it, as the Kane CLI assurance context docs describe.
  • Review - kane-cli context review promotes the extracted use-cases you approve. Extraction is an AI agent's work, so check each use-case against your EARS lines here.
  • Design - kane-cli design tests --use-case <uc-id> writes acceptance criteria with oracles, scenarios and exactly one test per scenario as *_test.md files, pausing after each phase for your approval. Where the requirements leave a value out, such as a store URL, the test uses a variable like {{store_url}} for you to fill in.
  • Run - kane-cli testrun run runs every *_test.md file under the current folder as one suite in Chrome, with one summary, one exit code and one sealed evidence pack.
  • Report - kane-cli cover reads the newest evidence pack and shows which acceptance criteria that run proved, next to what the design still owes.

Install Kane CLI with npm, which needs Node.js 18 or newer and Google Chrome, or with Homebrew on macOS and Linux, which needs no Node and bundles Chrome, according to the Kane CLI installation docs. Kane CLI is free to install. Extraction, test design and test runs use KaneAI credits, while list, review, explain and cover run locally at no cost, and new users can claim 10,000 credits, valid for 30 days, on TestMu AI's Kane CLI page.

The spec-driven development command line walkthrough shows the same loop on a Spec Kit spec, and Kiro powers Kane CLI verification sets up a Kiro power so that Kiro's agent can run these checks itself. The Kane CLI quickstart covers installing and signing in.

Conclusion

Start with a requirements file your team already has and rewrite each line into an EARS pattern, with one response per SHALL. Then read the response clause of each line and ask what a test would check after the action. Any line without a clear answer goes back to its owner before a test is written for it.

To keep new EARS requirements testable, add the lint script from this guide as a CI step. It sets a non-zero exit code when a line has no observable response, a vague word or IF without THEN, so a pull request that adds such a line fails the check.

Testing from the terminal? Kane CLI by TestMu AI lets SDETs and developers plan, write, run and debug tests from the command line.

To run your first test, start free, or
for a full walkthrough of the product.

Was this helpful?

Authors

Himanshu Sheth

Himanshu Sheth

Author · 130 hubs

Himanshu Sheth is the Director of Marketing (Technical Content) at TestMu AI, with over 8 years of hands-on experience in Selenium, Cypress, and other test automation frameworks. He has authored more than 130 technical blogs for TestMu AI, covering software testing, automation strategy, and CI/CD. At TestMu AI, he leads the technical content efforts across blogs, YouTube, and social media, while closely collaborating with contributors to enhance content quality and product feedback loops. He has done his graduation with a B.E. in Computer Engineering from Mumbai University. Before TestMu AI, Himanshu led engineering teams in embedded software domains at companies like Samsung Research, Motorola, and NXP Semiconductors. He is a core member of DZone and has been a speaker at several unconferences focused on technical writing and software quality.

Mayank Bhola

Mayank Bhola

Reviewer

Mayank Bhola is Co-Founder and Head of Products at TestMu AI, where he leads the entire product portfolio across KaneAI, Kane CLI, HyperExecute, SmartUI, the Real Device Cloud, Accessibility, and other software testing product lines. As an early Lead Architect he designed and built the company's flagship Tunnel technology from scratch, created the React-based automation platform, and architected the data-intensive pipelines and FAAS services that scale it. He brings more than 10 years of experience in software development and product engineering, with earlier roles as Head of Technology at Juggernaut Books and Senior Software Engineer at PressPlay TV and Zomato. Mayank holds a B.Tech in Computer Engineering from JIIT Noida.

EARS Requirements FAQs

TestMu AI forEnterprise

Get access to solutions built on Enterprise
grade security, privacy, & compliance

  • Advanced access controls
  • Advanced data retention rules
  • Advanced Local Testing
  • Premium Support options
  • Early access to beta features
  • Private Slack Channel
  • Unlimited Manual Accessibility DevTools Tests