Test cases in software testing: template, examples and design techniques
Short answer
A test case is a written check of one specific behaviour of your software. It lists the starting conditions, the exact steps, the test data and the result you expect. Someone runs the steps, compares what happened with what was expected, and marks the test passed or failed. A failed test case is the start of a bug report.
This guide covers what goes into a test case, a template you can copy, three worked examples, the difference between a test case and a test scenario, and the design techniques testers use to decide which cases to write. It is written from how our engineers write and maintain test cases on client projects every day.

The parts of a test case
Teams and tools name the fields differently, but a usable test case always answers the same questions: what are we checking, what must be true before we start, what exactly do we do, with which data, and what should happen. Everything else is there to make the case findable, traceable and easy to report on.
| Field | What it holds | Why it matters |
|---|---|---|
| ID | A unique reference, such as TC-LOGIN-004 | Bug reports, results and requirements can point at it |
| Title | One line saying what is checked | Someone scanning a list knows what the case is for without opening it |
| Requirement | The user story or requirement it covers | Shows which requirements are tested and which are not |
| Preconditions | What must be true before step 1: account state, data, environment | Most "cannot reproduce" arguments start with a missing precondition |
| Test data | The exact values to use | "Enter a valid email" gives ten testers ten different tests |
| Steps | Numbered actions, one action per step | Anyone on the team can run it the same way |
| Expected result | What the software should do, stated so it can be checked | Without it there is no pass or fail, only an opinion |
| Actual result | What happened when the case was run | The evidence behind a pass, and the first line of a bug report |
| Status | Passed, failed, blocked or not run | Feeds the release decision |
| Priority | How much the case matters if time runs out | Tells the team what to run first before a release |
The expected result is the field people most often get wrong. "Login works" cannot fail. "The user lands on /dashboard within 2 seconds and sees their name in the header" can. We wrote a separate guide on writing expected results because the same rule decides whether a bug report is useful.
A test case template you can copy
This is the layout our engineers start from when a client has no test management tool yet. It works in a spreadsheet, a Jira issue or a test management tool, because every tool has the same fields under different names.
| Field | Your entry |
|---|---|
| ID | TC-[AREA]-[NUMBER] |
| Title | [Feature] [does what] when [condition] |
| Requirement | [Story or requirement ID] |
| Priority | High / Medium / Low |
| Preconditions | [Account, data and environment state before step 1] |
| Test data | [Exact values] |
| Steps | 1. [One action] 2. [One action] 3. [One action] |
| Expected result | [What the user sees or the system records, specific enough to fail] |
| Actual result | [Filled in when run] |
| Status | Passed / Failed / Blocked / Not run |
Write the title so it reads as a sentence about behaviour: "Login rejects a wrong password and keeps the email filled in" tells a reviewer far more than "Login test 4".

Three test case examples
Example 1: login with a wrong password
| ID | TC-LOGIN-004 |
| Title | Login rejects a wrong password and keeps the email filled in |
| Preconditions | An active account exists for anna@example.com. The user is logged out. |
| Test data | Email: anna@example.com. Password: WrongPass1 |
| Steps | 1. Open /login. 2. Enter the email. 3. Enter the password. 4. Click "Log in". |
| Expected result | The user stays on /login. The message "Email or password is incorrect" appears under the form. The email field still shows anna@example.com and the password field is empty. No session cookie is set. |
Note what the expected result does not say: it does not reveal whether the email or the password was wrong. Telling an attacker which accounts exist is a security defect, so a good test case checks the wording as well as the redirect.
Example 2: card payment declined
| ID | TC-PAY-012 |
| Title | Checkout shows a clear message and keeps the order when the card is declined |
| Preconditions | Payment provider in test mode. Cart contains one item at 49.00 EUR. |
| Test data | The provider's published test card number for "card declined" |
| Steps | 1. Go to checkout. 2. Enter the test card. 3. Click "Pay". |
| Expected result | The page says the payment was declined and offers another card. The order is saved as "payment failed", not "paid". No confirmation email is sent. The cart still contains the item. |
Payment cases are where we see the most expensive misses, because the screen can look right while the order status underneath is wrong. Our guide to testing card types lists the scenarios worth covering.
Example 3: file upload over the size limit
| ID | TC-UPLOAD-007 |
| Title | Upload refuses a file just over the 10 MB limit with a message |
| Preconditions | Logged in as a user with upload rights. Limit configured at 10 MB. |
| Test data | A PDF of 10.1 MB |
| Steps | 1. Open the documents page. 2. Click "Upload". 3. Choose the file. |
| Expected result | The upload is refused before it finishes. The message names the 10 MB limit. Nothing is stored on the server. |
The 10.1 MB file is chosen on purpose: it sits just past the limit, which is where size checks break. The section on boundary value analysis below explains why. For the full set of upload checks, see our file upload testing cheat sheet.
Test case vs test scenario vs test script
The three words get mixed up constantly. The difference is how much detail each one carries.
| Test scenario | Test case | Test script | |
|---|---|---|---|
| What it is | A situation worth testing | Exact steps, data and expected result for one check | Code that runs a test case automatically |
| Example | "User logs in with wrong details" | TC-LOGIN-004 above | A Playwright or Cypress test that performs TC-LOGIN-004 |
| Detail | One line | A full page of steps and data | Executable code |
| Written by | Tester or analyst, early | Tester | Automation engineer |
| How many | One scenario usually becomes several cases | Several per scenario | One per automated case |
A practical order: list the scenarios first so nothing obvious is missed, write test cases for the scenarios that carry the most risk, then automate the cases you will run on every release.
Types of test cases
Most projects need a mix. The list below is the set we plan for on a typical web or mobile product.
- Functional: does the feature do what the requirement says.
- Negative: does it handle wrong input, missing data and unexpected actions without breaking. See positive and negative testing.
- Boundary: does it behave at the edges of allowed values.
- Regression: does existing behaviour still work after a change. See how to choose what to run.
- Integration: do two parts, or your product and a third-party service, work together.
- UI and usability: can a person actually complete the task.
- Accessibility: can people using a keyboard or a screen reader complete it.
- Performance: does it stay fast under realistic load.
- Security: can it be misused, for example by reading another user's data.
- User acceptance: does the business owner agree it does the job.
Test case design techniques, with examples
Design techniques answer the hard question: out of the endless inputs a feature accepts, which few do you actually test? The ISTQB Foundation syllabus (CTFL 4.0.1, chapter 4) groups them into three families: black-box, white-box and experience-based. It adds collaboration-based approaches as a separate topic. Most of the cases we write come from the first family.
Specification-based (black box) techniques
These work from the requirement alone, without looking at the code.
Equivalence partitioning. Split the inputs into groups the software should treat the same way, then test one value from each group. If a form accepts ages 18 to 65, there are three groups: under 18, 18 to 65, and over 65. Three test cases, with ages 12, 40 and 70, cover what three hundred would.
Boundary value analysis. Bugs collect at the edges, where a developer typed < instead of <=. For the same age field, test 17, 18, 65 and 66: the last value outside, the first value inside, the last value inside, the first value outside again. This is the technique behind the 10.1 MB file in example 3. Testing each boundary value and its closest neighbour in the next partition, as done here, is called two-value boundary value analysis. The syllabus also describes a three-value version, which tests each boundary value and both of its neighbours: 17, 18 and 19, then 64, 65 and 66.
Decision table testing. When the result depends on several conditions together, list every combination in a table so none is forgotten. A discount rule shows why:
| Rule | 1 | 2 | 3 | 4 |
|---|---|---|---|---|
| Customer is a member | Yes | Yes | No | No |
| Order over 100 EUR | Yes | No | Yes | No |
| Expected discount | 15% | 10% | 5% | None |
Each column becomes one test case. Teams that test only the first and last column miss the two middle rules, which is where conditions usually get combined wrongly in code.
State transition testing. For anything that moves between states, test the transitions, including the ones that should be impossible. An account that locks after three failed logins has the states active, locked and unlocked. Test cases cover the third failure locking the account, a correct password not unlocking a locked account, and the unlock link restoring access.
Use case testing. Follow a complete user journey end to end, such as "a new customer signs up, buys, and receives an invoice", to catch problems that only appear when the steps run in sequence. Use case testing was a named technique in older Foundation syllabi. CTFL 4.0.1 no longer lists it among the black-box techniques and it is now covered at Advanced Level (Test Analyst) under scenario-based testing, but it remains a useful way to write end-to-end cases.
Structure-based (white box) techniques
These look at the code and measure how much of it the tests exercise. Statement coverage asks whether every executable statement ran at least once. Branch coverage asks whether every branch was taken, including both outcomes of each decision, the "if" and the "else". Any set of tests that reaches 100% branch coverage also reaches 100% statement coverage, but not the other way round, and neither proves the code is free of defects. They are mostly used by developers in unit tests, and they are good at showing what was never tested, not at proving what works.
Experience-based techniques
Error guessing uses what a tester has seen break before: empty fields, pasted text with trailing spaces, a double click on "Pay", a session that expired mid-form. Exploratory testing is structured investigation without a script, with notes, which often finds the cases nobody thought to write down. Checklist-based testing turns those lessons into a reusable list. The syllabus also covers collaboration-based approaches, which aim to prevent defects through conversation: writing user stories together, agreeing acceptance criteria, and acceptance test-driven development (ATDD).
In practice we combine them: partitions and boundaries for inputs, decision tables for business rules, state transitions for workflows, and a timeboxed exploratory session on every new feature to catch what the specification missed. Our test techniques service page describes how we apply them on client projects.
How to write a good test case
- Check one behaviour per case. If a case can fail for two different reasons, split it, or the failure will not tell you what broke.
- Make the expected result able to fail. Name the page, the message, the value or the record.
- Give exact test data. Values, not descriptions of values.
- State every precondition. Account type, feature flags, data that must already exist.
- Keep cases independent. A case that only passes after another case has run will fail for the wrong reason the day the order changes.
- Write for someone new. A tester who joined last week should be able to run it without asking.
- Link each case to a requirement. That is how you see which requirements have no tests.
- Retire what no longer applies. An outdated case that fails every run teaches the team to ignore failures.
We collected the mistakes we see most in reviews in common mistakes to avoid in test cases.
How many test cases do you need?
There is no correct number per feature, and a high count is not a sign of good coverage. What matters is that the risky behaviour is covered. We decide in three passes: list the scenarios for the feature, rank them by how much damage a failure would do and how likely it is, then write cases for the top of the list using the techniques above, and stop when the next case would only repeat a partition or boundary already tested.
A login form usually needs between ten and twenty cases once you count wrong passwords, locked accounts, expired sessions and password reset. A payment flow needs more, because each payment method and failure has its own path. Your test plan is the place to write down what is in scope and what is deliberately left out.
Where to keep test cases
A spreadsheet is fine for the first few dozen cases. After that, teams move to a test management tool so they can track runs, link cases to requirements and bugs, and see results per release. Common choices are Jira with a test add-on, TestRail and Azure DevOps Test Plans. We built our own, BugBoard, and we also work in whatever tool a client already uses.
Whichever tool you choose, keep the cases where your team can still read them if the tool or the vendor changes. Software can now draft a first version of test cases from a requirement in seconds, and we use that, but a person still reviews every case before it counts. Our article on generating test cases with a human review explains where drafts go wrong.
Frequently asked questions
Want test cases written and kept up to date for you?
Our engineers write, run and maintain test cases in your own tools, so the work stays with you. The first month is a trial on your product. If you are not happy, the first two weeks are complimentary.
Book a call Managed testing services