Structure and importance of test case
Learning Objectives
By the end of this lesson, you will be able to:
- Understand what a test case is.
- Know why test cases are important.
- Identify all sections of a test case.
- Write effective test cases.
- Avoid common mistakes.
- Answer interview questions confidently.
What is a Test Case?
A test case is a documented set of inputs, actions, and expected results used to verify that a software feature works correctly.
Think of it as a recipe.
Just as a recipe tells you:
- Ingredients
- Steps
- Expected dish
A test case tells the tester:
- Preconditions
- Steps
- Test data
- Expected results
Example
Suppose you’re testing a login page.
Instead of saying
Test Login
A proper test case would be
| Field | Value |
|---|---|
| Test Case ID | TC_LOGIN_001 |
| Title | Verify successful login |
| Preconditions | User account exists |
| Test Data | Username: admin Password: Admin123 |
| Steps | Open Login page → Enter credentials → Click Login |
| Expected Result | Dashboard should open |
This allows any tester to execute the same test consistently.
Why Are Test Cases Important?
Without test cases:
- Everyone tests differently.
- Bugs are missed.
- Regression testing becomes difficult.
- New testers struggle to understand what to test.
With test cases:
- Consistency
- Repeatability
- Better coverage
- Easier automation
- Easier knowledge transfer
Structure of a Test Case
A good test case contains these sections:
Test Case ID
Title
Module
Priority
Requirement ID
Preconditions
Test Data
Test Steps
Expected Result
Actual Result
Status
Comments
Let’s understand each one.
1. Test Case ID
Unique identifier.
Example
TC_LOGIN_001
TC_CART_005
TC_PAYMENT_020
Why?
Easy tracking in Jira, Azure DevOps, or test management tools.
2. Title
Short description.
Good
Verify login with valid credentials
Bad
Login Test
A good title clearly explains what is being verified.
3. Module
Which feature?
Examples
- Login
- Checkout
- Reports
- User Management
4. Priority
How important is the test?
| Priority | Meaning |
|---|---|
| High | Critical business function |
| Medium | Important |
| Low | Nice to have |
Example
Login
High
Profile Picture Upload
Low
5. Requirement ID
Links the test case to a requirement.
Example
REQ-101
US-230
BR-15
Useful for traceability.
6. Preconditions
What must exist before testing?
Example
Application is running
User account exists
Database available
Internet connected
Without preconditions, someone else may not be able to execute the test correctly.
7. Test Data
Test data is data that is used during testing.
Example
Username
admin@test.com
Password
Password123
Sometimes include:
- Product ID
- Customer Number
- Order Number
- Warehouse Location
- PLC Number
8. Test Steps
Step-by-step actions.
Example
- Open Login page
- Enter username
- Enter password
- Click Login
Each step should be simple and clear.
9. Expected Result
What should happen?
Example
Dashboard opens successfully.
Not
Login works.
Expected results should be measurable.
10. Actual Result
Filled after execution.
Example
Dashboard opened successfully.
or
Error displayed
11. Status
Usually
- Pass
- Fail
- Blocked
- Not Executed
- Skipped
12. Comments
Extra observations.
Example
Issue reproduced only on Chrome.
Complete Example
| Field | Value |
|---|---|
| Test Case ID | TC_LOGIN_001 |
| Title | Verify successful login |
| Priority | High |
| Preconditions | Registered user exists |
| Test Data | admin / Admin123 |
| Steps | Open Login → Enter username → Enter password → Click Login |
| Expected Result | User is redirected to Dashboard |
| Actual Result | Dashboard displayed |
| Status | Pass |
Characteristics of a Good Test Case
A good test case is:
- Clear
- Simple
- Repeatable
- Independent
- Easy to understand
- Traceable to requirements
- Reusable
Common Mistakes
❌ Too many actions in one step
Bad
Open login page, enter username, enter password, click login, verify dashboard.
Better
Step 1 Open Login page
Step 2 Enter username
Step 3 Enter password
Step 4 Click Login
Step 5 Verify Dashboard
❌ Vague expected results
Bad
System works.
Better
Dashboard page opens and displays the logged-in user's name.
❌ Missing test data
Never assume everyone knows which data to use.