Guide

How to write test cases from requirements, with examples

Make each requirement testable, find its inputs and limits, write positive, negative and boundary cases, and trace every test back to its requirement.

What a requirements-based test case contains

A test case is useful when someone else can run it and reach the same verdict. For hardware and embedded products that means every test case names the requirement it verifies, the state the device must be in, the exact input, the steps and the result that decides pass or fail.

The fields of a test case
FieldWhat it holds
Test case IDA unique, stable identifier, for example TC-F-001 for a functional test and TC-S-001 for a system test.
TitleWhat is tested, in one line.
Requirement referenceThe ID of the requirement (or requirements) it verifies. This is what makes traceability possible.
Test typeFunctional, system or non-functional.
CategoryPositive (valid input, expected behaviour), negative (invalid input or a fault) or boundary (at or just beyond a limit).
PriorityHow important the test is, usually from the risk of the requirement.
ObjectiveThe behaviour the test proves.
PreconditionsThe state of the device and the test bench before the first step.
Test dataThe exact values used.
StepsNumbered actions, one action per step.
Expected resultObservable and measurable: a value, a message, a signal, a time.
StatusNot executed, pass, fail or blocked, filled in when the test is run.

The free functional and system test case templates linked at the end of this article use exactly these columns.

Step 1: make the requirement testable

Before writing a test, read the requirement as a tester. A testable requirement describes one behaviour, has a measurable acceptance criterion and states its limits. Take two requirements from an infotainment sample project:

  • SYS-AUD-004: "Bass and treble shall be adjustable from -10 to 10 in steps of 1." Testable: the range and the step are stated.
  • SYS-AUD-005: "The system shall apply the last selected audio profile within 2 seconds after ignition ON." Testable, but it raises a question: what happens on the very first ignition, when no profile was ever selected?

Write such questions down and get them answered before the tests are final. An unanswered question is a test that cannot be judged.

Step 2: find the inputs, the outputs and the limits

List what the requirement takes in, what it produces and where its limits are. The limits are where most defects hide.

Inputs and limits of two sample requirements
RequirementInputValid rangeOutput to observe
SYS-AUD-003 (profile name)Name length and characters3 to 20 characters; letters, digits and spacesName accepted or rejected
SYS-AUD-004 (bass, treble)Bass or treble value-10 to 10, steps of 1Applied setting
SYS-AUD-006 (speed lock-out)Vehicle speedTouch-screen changes allowed up to 5 km/h; blocked aboveTouch-screen change accepted or blocked

Step 3: write positive, negative and boundary cases

Split every input into equivalence partitions (values the system should treat the same way) and test each partition once. Then test the boundaries: the first and last valid value and the first invalid value on each side.

Partitions and boundaries for SYS-AUD-003 (name length 3 to 20)
CategoryValueExpected
Boundary (invalid)2 charactersRejected
Boundary (valid)3 charactersAccepted
Positive10 characters, letters and a spaceAccepted
Boundary (valid)20 charactersAccepted
Boundary (invalid)21 charactersRejected
Negative"Rock!" (a character that is not allowed)Rejected

Read the wording of a limit carefully. SYS-AUD-006 blocks changes while the speed exceeds 5 km/h, so 5 km/h itself is still allowed. The boundary tests are therefore at 5 km/h (change accepted) and just above it, for example 6 km/h (change blocked), plus the speed resolution your bench can actually set.

Step 4: write the test case

A functional boundary test for SYS-AUD-004, written out in full:

TC-F-001, a functional boundary test
FieldValue
Test case IDTC-F-001
TitleBass accepts its upper limit of 10 and stops there
Requirement referenceSYS-AUD-004
Test type / category / priorityFunctional / Boundary / High
ObjectiveShow that bass can be set to 10 and that the control does not go beyond 10
PreconditionsHead unit on; Settings > Audio open; bass at 9
Test dataBass 9 → 10 → one more step up
Steps1. Press bass + once. 2. Read the displayed value. 3. Press bass + once more. 4. Read the displayed value.
Expected resultStep 2 shows 10. Step 4 still shows 10; no value above 10 is applied.

And a system test for an embedded requirement from a bootloader and OTA sample project, REQ 4: "After an update the new image shall confirm itself within 30 seconds of start-up; otherwise the bootloader shall roll back to the previous slot on the next reset."

TC-S-001, a system negative test
FieldValue
Test case IDTC-S-001
TitleAn update that never confirms itself is rolled back on the next reset
Requirement referenceREQ 4
Test type / category / prioritySystem / Negative / High
PreconditionsDevice running image version N in slot A; an update image N+1 that is built not to confirm itself
Steps1. Install N+1 (written to slot B). 2. Let it start and wait longer than 30 seconds. 3. Reset the device. 4. Read the running version and the active slot.
Expected resultAfter step 3 the device runs version N from slot A; the update status reports rolled back.

Agree the timing tolerance before the test is run: "within 30 seconds" needs a stated measurement method and resolution, otherwise a confirmation at 30.2 s cannot be judged.

Step 5: trace every test to its requirement

A requirements traceability matrix (RTM) lists every requirement with the tests that verify it. It answers the question a reviewer will ask: which requirements are not tested yet?

Part of a traceability matrix
RequirementTest casesPositiveNegativeBoundaryStatus
SYS-AUD-003TC-F-010 … TC-F-015114Covered
SYS-AUD-004TC-F-001, TC-F-002002Partially covered
SYS-AUD-008—000Not covered

A practical rule: call a requirement covered when it has at least one positive test and at least one negative or boundary test. SYS-AUD-004 above has boundary tests only, so a positive test (for example bass set to 0) is still missing.

Common mistakes

  • Testing only the happy path: no negative or boundary cases.
  • Expected results that cannot be measured, such as "works correctly".
  • Several behaviours in one test case, so a failure does not say what broke.
  • Missing preconditions, so the test only passes on the bench of the person who wrote it.
  • Tests that name no requirement, so coverage cannot be shown.
  • Off-by-one limits: "exceeds 5" and "at least 5" need different boundary values.

Checklist

  • Every requirement is testable: one behaviour, a measurable criterion, stated limits
  • Open questions are written down and answered
  • Each input is split into valid and invalid partitions
  • Boundaries are tested on both sides
  • Every test case has preconditions, exact test data, numbered steps and a measurable expected result
  • Every test case names its requirement
  • The traceability matrix shows no requirement without a positive and a negative or boundary test

Do it faster with MithraTiny Test Case Generator Agent

Turn requirements into functional and system test cases, with a traceability matrix and a coverage report.

Sources

  1. ISO/IEC/IEEE 29119-4, Software and systems engineering — Software testing — Part 4: Test techniques. ISO/IEC/IEEE, Equivalence partitioning and boundary value analysis.

By MithraTiny AI Labs · Published 2026-11-25

Put an AI Engineer on your next board

Where Engineering Meets Super Intelligence. Free to start, AI included.