How to Write Test Cases

Harry · 21 Sep 2026 · 2 views
Log in to track your progress and mark lessons complete.

What is a Test Case?

A test case is a documented set of steps, data and expected results used to verify one behaviour. Test Scenario is the what (verify login); Test Case is the how (steps with data).

Test Case Template

ID: TC_LOGIN_001
Title: Valid user can log in
Preconditions: user registered, on /login
Steps: 1. Enter email 2. Enter password 3. Click Login
Data: user@test.com / Pass@123
Expected: redirect to /dashboard, welcome banner shown
Severity: Critical | Priority: High

Good Test Case Habits

  • One behaviour per case, independent and repeatable.
  • Use real representative data, plus one negative case per field.
  • Name expected results exactly (text, URL, status code).
  • Keep steps atomic so anyone can execute them.

Test Data

Prepare valid, invalid, boundary and empty data sets. Mask PII; refresh data between runs so tests never depend on execution order.

Anatomy of a test case - ID, steps, test data, expected result

Key Points

  • Scenario groups cases; cases prove behaviour.
  • A case without expected results is just exploration notes.
  • Negative cases find more bugs than happy paths.
Share this post:

Comments (0)

Please login or register to comment.

Create a free account to keep reading

You've enjoyed a free tutorial! Register (it's free) to unlock every tutorial, track your progress and save code.

or sign in with your account

Already have an account? Log in