← Testing and quality guides

How to review whether a spec is testable

How-To Testing and quality Intermediate 1131007HOWTO-1131007

HOWTO-1131007Testing and qualityIntermediate

This guide shows you how to review whether a SpecDD spec is testable in a spec-driven development workflow.

A spec can look clear in prose and still be hard to verify. It may use subjective language, hide important inputs, combine several responsibilities, omit expected outcomes, or define Done when criteria that do not name actual evidence.

Testability review catches those problems before implementation starts. The goal is not to force every spec entry into a unit test. The goal is to make sure important behavior and constraints can be observed, checked, reviewed, or traced.

Short answer

A testable spec has a local subject, observable behavior, deterministic outcomes, concrete examples, practical negative constraints, and measurable Done when criteria. If a reviewer cannot say how a Must, Scenario, Must not, or Done when entry would be verified, revise the spec before using it for implementation.

When to use this guide

Use this guide when:

Testable does not always mean unit-testable

Some entries are best verified by:

The review question is not “can every line become a unit test?” The question is “can the important behavior or constraint be checked with appropriate evidence?”

Steps

1. Check the subject

Testability starts with scope:

Spec: Itinerary Validation

is easier to verify than:

Spec: Trip Improvements

If the subject is broad, tests will likely need broad setup. Split the spec or narrow the subject before implementation.

2. Check observable behavior

Good:

Must:
  Reject itinerary items without a place name.
  Preserve existing itinerary items when validation fails.

Weak:

Must:
  Handle bad input gracefully.

Observable behavior has inputs and outcomes a test or review can see.

3. Check deterministic outcomes

Ask:

If behavior is intentionally nondeterministic, specify the stable contract around it.

4. Check scenarios

A good scenario has concrete setup, action, and expected result:

Scenario: missing place name
  Given the place name is empty
  When the person adds the itinerary item
  Then validation fails
  And no itinerary item is stored

Weak:

Scenario: invalid input
  Given invalid input
  When it is handled
  Then it works correctly

Scenarios should not hide the important condition or outcome.

5. Check negative constraints

Must not and Forbids can be testable, but the evidence may vary.

Behavior boundary:

Must not:
  Save itinerary items after validation fails.

Possible evidence: regression test.

Dependency boundary:

Forbids:
  UI importing ../adapters/*

Possible evidence: static import check or code review.

If a negative rule is important and likely to regress, decide what evidence is appropriate.

6. Check Done when

Strong:

Done when:
  Missing-place validation is covered by a check.
  Validation failure preserves existing itinerary items.
  UI components do not import trip storage adapters.

Weak:

Done when:
  Tests pass.
  It is complete.

Done when should identify the behavior, boundary, or evidence that proves completion.

7. Revise vague entries before testing

Do not ask implementers to “figure out the tests” from a vague spec. First revise the spec:

Must:
  Show a validation message beside the place name input when the place name is missing.

is better than:

Must:
  Show a nice validation experience.

The revised rule can be checked.

Testability checklist

Use this checklist before implementation:

Common mistakes

How to verify the result

The spec is testable when:

← Testing and quality guides