Writing Good Test Cases
A test case is a set of steps, data and an expected result that checks one thing. Good test cases can be run by anyone on the team and give the same result.
Parts of a test case
- ID and title: TC_LOGIN_003 – Login fails with a wrong password
- Preconditions: a registered user exists; the user is logged out
- Steps: numbered, one action per step
- Test data: the exact values to use
- Expected result: what should happen, specific and checkable
- Priority: High, Medium or Low
Example
| Title | Login fails with a wrong password |
| Preconditions | User ana@example.com exists with password Secret123 |
| Steps | 1. Open the login page 2. Enter ana@example.com 3. Enter wrongPass1 4. Click Log in |
| Expected | The user stays on the login page and sees "Invalid email or password". The password field is cleared. |
Tips
- Test one thing per test case.
- Write the expected result before you run the test.
- Cover positive, negative and edge cases.
- Avoid vague words like "works properly". Say exactly what should be seen.
Practice: write five test cases for the practice register page, then run them.
All 12 lessons in Manual Testing
- What Is Software Testing?
- QA vs QC vs Testing
- The Software Testing Life Cycle (STLC)
- Levels of Testing
- Functional vs Non-functional Testing
- Smoke, Sanity and Regression Testing
- Writing Good Test Cases
- Equivalence Partitioning and Boundary Value Analysis
- Decision Tables and State Transitions
- The Bug Life Cycle
- Writing a Great Bug Report
- Severity vs Priority, and Your Final Practice