What a test case is, the fields it needs, the main types, how to write one step by step, and worked examples you can copy.
Test cases turn a requirement such as "registered users can log in" into checks anyone on the team can repeat and get the same answer. This guide covers what a test case is, the fields it needs, the main types, how to write one step by step, and test case examples for a web application.
What is a test case?
A test case in software testing is a set of preconditions, steps, test data, and an expected result that checks whether one specific behavior of an application works as intended. A tester follows the steps, compares what actually happens with the expected result, and marks the test case as passed or failed.
It's the smallest unit of testing work: one condition, one set of steps, and one expected outcome. When a test case fails, the tester reports a bug.
Test cases sit between the high-level plan and the actual run:
- A test plan sets the scope, approach, and schedule.
- A test scenario names something to test, such as "user login".
- A test case spells out exactly how to test one part of that scenario, such as "login fails with a wrong password".
- A test run is one execution of a set of test cases against a build.
Written test cases are part of your test documentation. They let a new team member run a check without asking how, keep results comparable from one release to the next, and show which requirements have been tested. Manual testing runs on them, and good manual test cases are also the starting point for automated ones.
Test case example: web application login
Here is a complete test case for the login page of an online store. The data is illustrative.
Field | Value |
|---|---|
Test case ID | TC-LOGIN-001 |
Title | Log in with a valid email and password |
Requirement | US-112: Registered users can log in with email and password |
Priority | High |
Preconditions | An active account exists for shopper01@example.com. The user is logged out and on the login page. |
Test data | Email: shopper01@example.com. Password: the account's valid password from the test data sheet. |
Steps | 1. Enter the email. 2. Enter the password. 3. Select Log in. |
Expected result | The account page opens and shows "Hi, Shopper". The header shows Log out instead of Log in. |
Actual result | Filled in after the run |
Status | Not run |
That's the positive case: valid input, expected success. Most positive cases need at least one negative partner that checks the application handles bad input safely. Here are both, side by side:
Field | Positive: TC-LOGIN-001 | Negative: TC-LOGIN-002 |
|---|---|---|
Title | Log in with a valid email and password | Log in with a valid email and a wrong password |
Preconditions | Active account, logged out, on the login page | Same |
Test data | Valid email, valid password | Valid email, password "Wrong-Pass-1" |
Steps | Enter email, enter password, select Log in | Same |
Expected result | Account page opens; header shows Log out | Login page stays open and shows "Email or password is incorrect". The password field is cleared. The user isn't logged in. |
The negative case's expected result is just as specific as the positive one. "An error appears" isn't enough: name the message, and say what must not happen.
For more login checks, see these 100 login page test cases.
Components of a test case
Most teams use the fields below. Environment, postconditions, and attachments are optional for many teams.
Field | What it means | Example |
|---|---|---|
Test case ID | A unique ID, usually a module prefix plus a number, so the case can be tracked and referenced | TC-LOGIN-001, TC-CART-014 |
Title | What the case checks, in one line. Start with a verb | Log in with a valid email and password |
Requirement | The user story or requirement the case covers, for traceability | US-112 |
Priority | How important the case is to run, based on risk and use | High, Medium, Low |
Preconditions | What must be true before step 1 | User is logged out and on the login page |
Test data | The exact inputs to use | shopper01@example.com |
Steps | Numbered actions, one action per step | 1. Enter the email |
Expected result | The observable outcome that means the case passes | Account page opens and shows "Hi, Shopper" |
Actual result | What happened when the case was run | Account page opened as expected |
Status | The state of the case for this run | Not run, Pass, Fail, or Blocked |
Environment | Where the case was run | Chrome on Windows, staging |
Postconditions | The state the case leaves behind, so the next case can start clean | User is logged in; log out before the next case |
Notes and attachments | Screenshots, logs, or the linked bug for a failure | BUG-2087 with a screenshot |
Fill in ID through expected result, plus postconditions and the target environment, before the run. Actual result, status, and attachments are recorded during or after it. A blocked case couldn't be run, for example because the test environment was down. That isn't the same as a failure.
To trace each test case back to its requirement across a whole release, use a requirements traceability matrix. For a ready-made layout with these fields in Excel, Word, and PDF, download our test case template.

Types of test cases
Test cases are usually grouped by what they check:
- Functional: the feature does what the requirement says. Adding a product updates the cart count.
- Negative: the application handles invalid input or actions safely. Checkout rejects an expired card with a clear message.
- Boundary (edge): values at and just past the limits. A quantity field that accepts 1 to 10 is tested with 0, 1, 10, and 11. See boundary value analysis.
- UI: layout, labels, and visual states. The Log in button is disabled until both fields are filled.
- Integration: two parts of the system work together. Placing an order creates a matching record in the warehouse system.
- Non-functional: performance, security, usability, and accessibility. Search returns results in under 2 seconds with 500 products.
- Regression: existing features still work after a change. Login still works after the password reset flow is rebuilt. See regression testing.
- Smoke: a short set of critical checks on every new build. The home page loads, login works, and a product can be added to the cart.
- User acceptance (UAT): business users confirm the feature meets their needs. A store manager can issue a refund from the admin panel.
- Database: data is stored and changed correctly. Deleting an account removes the user's saved addresses.
Positive and negative cases aren't separate pieces of work. They're two sides of the same requirement: in most cases, write the positive case first, then its negative and boundary partners. For a broader view of testing types, see different types of QA testing.
How to write a test case (step by step)
These steps apply to manual test cases, and the same structure carries over when you automate them later. The running example is a shopping cart quantity field.
- Read the requirement and its acceptance criteria. Know what "working" means before you write anything. If a rule is unclear, ask now. Example: "Shoppers can set a quantity from 1 to 10 for each cart item. The cart total updates as soon as the quantity field loses focus."
- List what to test. Break the requirement into scenarios and conditions: valid quantities, invalid quantities, the total, and what happens on page refresh. Example: change quantity, reject out-of-range quantity, recalculate total, keep quantity after refresh.
- Choose the conditions and test data. Use test case design techniques such as equivalence partitioning and boundary values so a few cases cover the range. Example: 1 and 10 (valid limits), 5 (a typical value), 0 and 11 (just outside), and "abc" (wrong type).
- Give each case an ID and a clear title. One behavior per case. If the title joins two separate checks with "and", it's probably two cases. Example: TC-CART-014 "Set quantity to the maximum of 10"; TC-CART-015 "Reject a quantity of 11".
- Write the preconditions. Say what must already be true, so anyone can start from the same state. Example: "Logged-in user. Cart contains one product priced $20.00 with quantity 1."
- Write the steps. One action per step, in the order the user does them. Describe what to do, not where every pixel is, so the case survives small UI changes. Example: 1. Open the cart. 2. Set the quantity to 10. 3. Move focus out of the field.
- Write a measurable expected result. State exactly what should happen, with values. Example: "Quantity shows 10. Line total and cart total both show $200.00. No error message." For TC-CART-015, starting from quantity 10 (total $200.00) and entering 11: "Quantity reverts to 10, the message 'Maximum quantity is 10' appears, and the total stays $200.00."
- Review, then run. Have a teammate read the case without your help. If they can't run it, rewrite it. Our test case review process has a checklist. Then run the case, record the actual result and status, and attach evidence for any failure.
Example: turning a vague test case into a clear one
Many test cases fail long before they're run, because nobody else can follow them. Here's a real-world kind of test case, rewritten:
Field | Vague | Clear |
|---|---|---|
Title | Check checkout | Pay for an order with a valid saved card |
Preconditions | None | Logged-in user with one saved Visa test card; cart has one item at $20.00; standard shipping is $5.00 |
Test data | Any card | Saved card ending 4242 |
Steps | Go through checkout and pay | 1. Open the cart. 2. Select Checkout. 3. Choose the saved card. 4. Select Pay now. |
Expected result | It works | Order confirmation page shows an order number and a total of $25.00 ($20.00 item plus $5.00 shipping). The cart is empty. |
What changed: a specific goal instead of "check checkout", exact data, a starting state anyone can reproduce, and an expected result someone else can check without guessing.
Test case vs test scenario vs test script
The three terms are often mixed up. Using the login example:
Test scenario | Test case | Test script | |
|---|---|---|---|
What it is | A high-level description of what to test | Detailed steps, data, and an expected result for one condition | Code that runs a test case automatically |
Example | Check user login | TC-LOGIN-002: Log in with a valid email and a wrong password; the error message appears and the user isn't logged in | A script that enters the email and wrong password, selects Log in, and asserts the error text |
Who uses it | Test leads planning coverage | Testers running checks, by hand or as the basis for automation | Automation tools and CI pipelines |
When to use it | Planning and early design | When a check must be repeatable and traceable | When a stable check runs often enough to automate |
One scenario usually becomes several test cases, and some of those test cases become scripts. For more detail, see test scenario vs test case and how to write a test script.
A related term: a test suite is a group of test cases run together, such as all checkout cases.
More test case examples
More sample test cases for other common features. Each one is a single case; a real set would add negative and boundary partners.
ID | Feature | Title | Expected result |
|---|---|---|---|
TC-SEARCH-003 | Search | Search with no matching results | "No results for 'xyzq'" appears, with suggested categories. No error page. |
TC-CART-021 | Cart | Remove the last item from the cart | Cart shows "Your cart is empty". Cart count in the header shows 0. |
TC-REG-007 | Registration | Register with an email that's already in use | Form shows "An account with this email already exists" and a link to log in. No new account is created. |
TC-API-012 | API | GET /orders/{id} with an ID that doesn't exist | Response is 404 with error code ORDER_NOT_FOUND. No order data is returned. |
Full sets by feature: registration page, search, ecommerce website, payment gateway, banking application, and API testing.
Best practices for writing good test cases
- Check one behavior per case. Small cases point straight at what broke. Split a case when you find yourself repeating "and then check".
- Write for someone new to the feature. Don't assume knowledge of the product, the test account, or where a setting lives.
- Make expected results measurable. Name the exact message, value, or state. "Works correctly" can't fail.
- Keep cases independent. Each case sets up its own preconditions, so cases can run in any order and one failure doesn't block the rest.
- Cover the unhappy paths. For each positive case, add negative and boundary cases. Boundaries are where many bugs hide.
- Link every case to a requirement. You'll know what's covered, and which cases to update when a requirement changes.
- Prioritize by risk. Not every case runs every cycle. Run high-risk, high-use cases first. See test case prioritization.
- Keep test data separate and reusable. Store accounts and inputs in one place rather than retyping them into every case.
- Review and retire. Update cases when the feature changes and archive the ones that no longer apply. Outdated cases waste run time and produce false failures.
- Don't script everything. For new or fast-changing features, a short exploratory testing session often finds more than a detailed case written too early.
Ready to automate? Stable, high-priority cases that run every release are the best candidates. Clear IDs, fixed test data, and independent preconditions make the move much easier. See how to write automation test cases, our guide to writing test cases in Selenium, and the Katalon Studio docs on creating test cases.
Using AI to draft test cases? AI test case generation can turn requirements into first drafts quickly, but the drafts still need a tester's review for missing edge cases and vague expected results. See how to review AI-generated test cases.
Where to keep your test cases
A spreadsheet works for a handful of cases. As the suite grows, teams move to a test case management tool so that cases, runs, results, and bugs stay linked and versioned.
In Katalon TestOps, you can write manual test cases with steps, test data, and expected results, or import existing ones from a CSV file. Once Jira or Azure DevOps is connected, you can link each case to its requirement and to related defects. Katalon AI can draft test cases and steps from a synced requirement for your team to review and save. When you run a case, you record a result for each step and attach screenshots or logs as evidence.

Frequently asked questions
A test case fails when the actual result doesn't match the expected result. The tester records what happened, attaches evidence such as screenshots or logs, and reports a bug with the steps to reproduce it. See our bug report template.
A test case describes how to check one behavior. A test run is one execution of a set of test cases against a specific build and environment, with a result recorded for each case. The same test case is run many times across releases.
Use a short prefix for the feature or module plus a number, such as TC-LOGIN-001 or TC-CART-014. Keep the format the same across the project, never reuse an ID, and don't change it when the case is edited.
There's no fixed number. Cover each acceptance criterion with at least one positive case, then add negative and boundary cases for every input and rule. Prioritize by risk, so the most important cases run first.
Write them during the sprint, from each user story's acceptance criteria, ideally before or alongside development. Keep them short, review them with the developer and product owner, and update them when the story changes.
Usually QA engineers or testers. Developers, business analysts, and product owners often contribute, especially to acceptance test cases, and they should review cases for their areas.
Yes, as a first draft. AI tools work best when the requirement has clear acceptance criteria. A tester still confirms the test data, preconditions, and expected results before the case is used.
A use case describes how a user interacts with the system to reach a goal, such as "buy a product". Test cases check that each part of that interaction works, including the error paths the use case may not mention.

Test everything. Ship with confidence.
From generating test cases to spotting failures, Katalon's AI works across your entire pipeline, automatically.



