Test case discovery

From event4u-app/agent-config · View interactive version

Test case discovery is an AI agent skill from the GitHub repository event4u-app/agent-config. Use BEFORE writing any test — enumerate cases per behavior (happy / boundary / error / abuse), prioritize by likelihood × impact, cross-check via subagent — even if the user just says 'add tests'.

How to use this skill

Skill file

test-case-discovery

AI-written test suites default to too few tests, mostly happy path. This skill is the discovery step that runs before the first test is written: enumerate what could break, pick the most important cases, then hand the list to CODE0 or the stack skill. The goal is breadth AND quality — happy path AND boundaries AND error paths — with a hard cap so the output is never a pile of trivial tests.

This is the before layer. Assertion quality is CODE0; after-the-fact coverage review is CODE1.

When to use

Do NOT use when:

The Iron Law

NO TEST IS WRITTEN BEFORE THE CASE LIST EXISTS.
ENUMERATE → PRIORITIZE → THEN WRITE. NEVER HAPPY-PATH-ONLY.
FLOOR PER BEHAVIOR: 1 HAPPY + 1 BOUNDARY + 1 ERROR (+1 ABUSE ON SECURITY PATHS).
CAP PER BEHAVIOR: 5–8 CASES — EACH MUST FAIL FOR A DISTINCT REASON.

Does this change owe an executable behavior contract?

This section is the decision Gherkin, BDD, Cucumber, Behat and

given-when-then are meant to reach — each pinned as a should-trigger case in

evals/triggers.json, with German exemplars for Cucumber and Behat. That

corpus specifies

the intent; it does not route, and this skill's description carries none of

the terms. A decision, not a guide to writing one.

Cases and contracts are not the same artifact. A case is something you assert

in the project's unit runner. An executable behavior contract — a

specification written in the language of whoever asked for the change, and run

by a tool that reads it — is a heavier thing, and most changes do not owe one.

Ask for one everywhere and it degrades into a second, slower unit suite; ask for

one nowhere and behavior nobody can read stays unstated.

The observable-behavior test

**Does this change alter behavior someone outside the code can observe, and

would that person describe it in their own words?**

Both halves have to hold: observable behavior with no outside audience is

still only a case. Observable rules out anything a caller cannot see. *In their own

words* rules out behavior that is real but has no audience outside the codebase —

if the only person who can state the rule is the person reading the

implementation, a case in the unit runner states it better and cheaper.

Yes → a contract is owed. A refund is issued when an order is cancelled

within 14 days; a member on a lapsed plan is denied the export; a rejected

upload tells the uploader which rule it broke.

No → cases, not a contract. At least these:

it, by definition. If something can, it was not a refactor.

retry backoff, connection-pool sizing, a query plan. Real behavior, no

audience — the failure is stated as a case, not as a sentence somebody outside

the code would say.

malformed UTF-8 sequence is a case; "we do not accept expired coupons" is a

contract.

written by the same team is a caller, not an audience. Contract tests between

services are a different tool and a different question.

When the answer is yes, the ordering is unchanged: the contract fails before the

implementation exists and passes after — see

CODE0. A contract

first seen green has the same unknown sensitivity as any other test never seen

red.

The anti-script rule

A CONTRACT STEP NAMING A SELECTOR, A TIMEOUT, OR A KEYSTROKE IS A DEFECT
IN THE CONTRACT — NOT AN IMPLEMENTATION DETAIL THAT HAPPENS TO BE THERE.
WRITE WHAT IS TRUE, NEVER WHAT IS CLICKED.

A contract that scripts the interface is pinned to the interface: it goes red on

every redesign that changes nothing anyone cares about, and stays green through

the redesign that breaks the rule. It also stops being readable by the person

whose words it was supposed to be in — which was the only reason to pay for it.

Wrong — this is a click script wearing Given-When-Then:

Given I open "/cart?id=42"
When I click #apply-coupon
And I type "SUMMER" into input[name=code]
And I wait 2 seconds
Then .cart-total should contain "€45.00"

Every line is about the page. Change the button id and it fails; move the

discount rule and it passes.

Right — same behavior, stated as the rule it is:

Given a cart of €50
When the customer applies a valid 10% coupon
Then the order total is €45

The rule survives the redesign, and the person who asked for it can read it.

The test for a step: could it still be true if the product were a CLI, an

API, and a web page? If not, it belongs in the implementation the contract calls

into, not in the contract.

Procedure — the five-step funnel

1. Behavior inventory (30 seconds)

List the 1–3 distinct observable behaviors the change introduces or modifies — one sentence each: "When X happens, the system should do Y." Each behavior gets its own case list. If you cannot state a behavior in one sentence, split it.

2. Dimension scan (per behavior)

Walk the dimensions below; mark 3–5 as HIGH (most likely to occur × highest impact when wrong). Skip dimensions the behavior structurally cannot hit — but say so, don't silently omit.

3. Case synthesis

Generate ≥ 1 concrete case per HIGH dimension, plus the happy path. Enforce the floor: 1 happy + 1 boundary + 1 error per behavior, +1 abuse case when the behavior is security-relevant. Name each case like a test (it rejects an expired token), not like a category ("error handling").

4. Subagent cross-check (gated, with mandatory fallback)

Widen the list with a second pair of eyes:

Unavailability of subagents never skips this step — it only switches the path.

5. Prioritize and cap

If a behavior collected more than 8 cases: rank by likelihood × blast radius, keep the top 5–8. Quality gate: each surviving case must be able to fail for a distinct reason (different code path / exception / assertion). The same assertion fed two interchangeable input values is ONE case — use a data provider, not a second test. Record dropped cases in one line each so the discovery work is not lost.

Then hand the list to CODE0 — every case runs its own RED → GREEN cycle — or to the stack skill (CODE1, CODE2, CODE3).

Output format

  1. The case matrix per behavior — case name → category (happy / boundary / error / abuse) → one-line why — in the reply or as a comment block atop the test file.
  2. The floor check, stated explicitly: floor met: happy ✓ boundary ✓ error ✓ (abuse: n/a — no security surface).
  3. The cross-check result: which path ran (subagent + lens, or degraded self-review) and which cases it added — or explicitly "none".
  4. Dropped/deferred cases with a one-line reason each.

Gotcha

Do NOT

Auto-trigger keywords

See also

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.