Software Testing

Beginner path · lesson 17 of 35

BeginnerTest design4 min readPublished November 12, 2026

How to write a good test case

A good test case can be run by anyone, gives the same verdict every time and checks one clear thing. Here's what to include, the mistakes to avoid and a before-and-after example.

On this page

Key takeaways

  • A good test case is clear enough that someone else can run it and reach the same verdict without asking you.
  • Each test case checks one thing, with concrete data and a specific expected result.
  • Write only as much detail as your team needs. Clear beats long.

What a test case is for

A test case is a precise description of one check. It lets a colleague, a new team member or future you run the same test and know whether it passed.

If two people can run your test case and disagree about the result, it isn't finished.

The parts of a test case

PartWhat to writeExample
IDA unique referenceTC-017
TitleWhat's checked, in one lineLogin fails with a wrong password
PreconditionsWhat must be true before startingUser ana@example.com exists with password Correct#123
StepsNumbered actions, one per line1. Open the login page. 2. Enter …
Test dataExact valuesEmail ana@example.com, password Wrong#123
Expected resultWhat should happen, preciselyError "Email or password is incorrect"; user stays on login page
LinkThe requirement or story it checksStory LOGIN-4

Many teams also add priority (how important the test is) and postconditions (how to clean up afterwards).

Before and after

Real-world exampleRewriting a vague test case

Before:

Title: Test login

Steps: Try logging in with wrong details.

Expected: It doesn't work.

What are "wrong details"? A wrong email, a wrong password, both? What does "doesn't work" look like: an error, a crash, a blank page?

After:

TC-017: Login fails with a wrong password

Preconditions: User ana@example.com exists, with password Correct#123. The user is logged out.

Steps:

  1. Open the login page.
  2. Enter email ana@example.com.
  3. Enter password Wrong#123.
  4. Click Log in.

Expected: The message "Email or password is incorrect" appears. The user stays on the login page. The password field is empty.

Lesson: the second version takes a minute longer to write. In return, anyone can run it, and everyone agrees whether it passed.

Seven habits of good test cases

  1. One purpose per test case. "Login fails with wrong password" and "Account locks after 5 failed attempts" are two test cases, not one.
  2. A title that says what's checked. Someone scanning a list of 200 tests should understand each one from its title.
  3. Concrete data. Not "a valid email", but ana@example.com. Not "a large amount", but 10,000.00.
  4. A specific, observable expected result. Exact messages, values and states. "Works correctly" isn't a result.
  5. Independent. Each test sets up what it needs, instead of relying on another test having run first.
  6. Traceable. Link it to the requirement or story it checks. When the requirement changes, you'll know which tests to update.
  7. Written for the reader. Use the product's real names for buttons and pages. Skip obvious steps like "turn on the computer".

Do

Write the expected result before running the test, based on the requirement. Then compare it with what actually happens.

Don't

Run the test first and write down whatever happened as the "expected result". You'll turn bugs into expected behaviour.

How much detail?

It depends on who'll use the test case.

  • Regulated industries (medical, banking, aviation) often need very detailed test cases as evidence for audits.
  • Small Agile teams may use short checklists: "Wrong password shows error, field cleared". That works when everyone knows the product well.
  • Tests that will be automated need precise steps and data, because code can't guess.

Check yourself

A test case's expected result says: 'The order is processed correctly.' What's wrong with it, and how would you fix it?

Show answer

It's not specific or observable. Two testers could disagree about what "correctly" means. A better version: "The confirmation page shows order number, total 149.90, and status Paid. A confirmation email arrives at ana@example.com. Stock for the product decreases by 1."