How to Write a Test Case (With Example)

Writing clear, accurate test cases is one of the most fundamental skills for any QA professional. Whether you’re manually testing or preparing for automation, good test cases ensure consistency, repeatability, and reliable defect detection.

In this post, you’ll learn:

  • What a test case is
  • What makes a test case effective
  • Step-by-step instructions
  • A reusable template
  • A real example

Let’s break it down.


✅ What Is a Test Case?

A test case is a set of detailed steps, input data, expected results, and conditions to verify that a specific part of the application works as expected.

🎯 Why Test Cases Matter:

  • Help ensure complete test coverage
  • Allow others to reproduce your tests
  • Support manual and automated testing
  • Track pass/fail status clearly

🧠 Key Elements of a Test Case

Here are the standard fields you should include in a test case:

FieldDescription
Test Case IDUnique identifier for tracking
Title/DescriptionBrief explanation of what’s being tested
PreconditionsConditions that must be met before test execution
Test StepsStep-by-step actions to perform
Test DataInputs required to perform the test
Expected ResultWhat should happen if the test passes
Actual ResultDocumented result after execution
StatusPass / Fail / Blocked
CommentsNotes, attachments, or observations

📝 How to Write a Test Case: Step-by-Step

Step 1: Understand the Requirement

Read the user story or feature description. Identify what needs to be verified.

Step 2: Define a Clear Title

Start with a short, specific statement like:
“Verify login with valid credentials.”

Step 3: List Preconditions

These are setup conditions before test execution.
Example: “User must be on the login page.”

Step 4: Write Detailed Steps

Each step should be clear, sequential, and easy to follow. Use consistent formatting and keep the language simple.

Step 5: Add Test Data

Mention any specific data needed (email, password, product ID, etc.).

Step 6: Define the Expected Result

What should happen if everything works correctly?

Step 7: Leave Room for Actual Result and Status

This will be filled out during or after test execution.


📋 Sample Test Case

FieldDetails
Test Case IDTC_001
TitleVerify login with valid credentials
PreconditionsUser is on login page; valid account exists
Test Steps1. Enter valid email
2. Enter valid password
3. Click “Login”
Test DataEmail: [email protected]
Password: Password123
Expected ResultUser is redirected to dashboard
Actual ResultUser redirected successfully
StatusPass
CommentsN/A

🙌 Final Tips for Great Test Cases

  • Use simple language – anyone should be able to follow it
  • Keep steps short and precise
  • Reuse test case IDs across sprints or releases for traceability
  • Group related test cases into test suites (e.g., Login Tests, Checkout Tests)
  • Regularly review and update old test cases

Leave a Reply

Your email address will not be published. Required fields are marked *