How to Write Test Cases Two Testers Will Agree On
A test case works when someone who didn't write it reaches the same pass or fail. Get the format, a six-step method, three examples and the mistakes to avoid.
To write a test case, pick one behavior, write down the setup and data it needs, list steps someone else can follow, and state a result they can check without asking you. Then give it to a teammate who didn’t write it. If they reach the same pass or fail you would have, the case is done.
The handoff is where a case gets its real test. You’re out the week of a release, a teammate covers your checkout pass, and every case comes back green. Two days later a customer pays $6.00 shipping on a $50.00 order, though the rule says orders of $50 or more ship free. Your case said “check that orders over $50 ship free,” and your teammate checked a $60 order, which did.
What you’ll learn
- The fields a test case needs, and the ones that belong to a run
- A six-step method that ends with a stranger test
- Login, checkout and search cases, rewritten from a weak first draft
- Five mistakes that split the verdict between two runners, or between two days
What Goes in a Test Case, and What Belongs to a Run
The ISTQB glossary defines a test case as a set of preconditions, inputs, actions, expected results and postconditions. On a working team that comes to six fields, with postconditions usually folded into the next case’s setup, plus a few that templates add and that go stale fast.
| Field | What it holds | Keep it? |
|---|---|---|
| ID | A stable handle, such as SHIP-014, that bug reports and runs point at | Yes, and never reuse one |
| Title | The behavior, in one sentence | Yes. It’s how the next person spots a duplicate |
| Preconditions | The state of the account, the app and the environment before step one | Yes |
| Test data | Exact values, or the name of a data set that creates them | Yes |
| Steps | One action each, in the words on the screen | Yes |
| Expected result | What the runner should see, with the value | Yes. Verdicts split here |
| Priority | How much a failure matters | Only if someone revisits it each release |
| Actual result, status, tester, date | What happened on one run | Move it to the run record |
The last row is the one I’d argue for. Plenty of templates, GeeksforGeeks’ included, put the actual result beside the expected one. It reads fine after the first run and wrong after the second. A case says what should happen every time, and a run records what happened once, so keep them in separate places and the case stays true after its hundredth run.
Bug reports and session notes are part of what a manual tester writes down, and they live outside the case as well. The case is only the instruction.
How to Write a Test Case in Six Steps
Each step closes one way a stranger could misread the case. The running example is an invented store where orders of $50.00 or more ship free and smaller orders pay $6.00, with no tax to keep the sums simple.
- Pick one behavior you could prove false. “Free shipping works” can’t fail in a useful way. “An order of exactly $50.00 ships free” can. Start from a requirement line or an acceptance criterion and write the behavior as one sentence.
- Choose the inputs that change the outcome. Values on either side of a rule behave differently, so test the edge and one value on each side of it, here $49.99, $50.00 and $80.00. Testers call this equivalence partitioning and boundary value analysis. Two more values inside the same band add nothing.
- Write the preconditions and data as facts. Write “signed in as [email protected], with an empty cart and a US address saved” in place of “a signed-in user”. The runner can set up the first one without asking you anything.
- Write steps a stranger can follow. One action per step, in the words on the screen: select Add to cart, open the cart, select Checkout.
- Write an expected result someone can check. The ISTQB glossary calls the expected result the “observable predicted behavior” of what you test, and observable is the word that matters. Write “Shipping reads $0.00 and the total reads $50.00”, worked out from the rule before anyone runs it. A value copied off the screen during the run only proves the app agrees with itself.
- Run the stranger test. Hand the case to someone who didn’t write it and ask for a verdict without explaining anything. Every question they ask is a missing line. A different verdict means the expected result still needs an opinion.
The same checks work on cases you didn’t write yourself. Drafting cases is now part of AI testing, and our guide to AI test case generation runs a similar review against a batch a model drafted, where the expected results are the part most likely to be guessed.
Whoever drafts the steps, the expected result is the feature owner’s call. I’d never let a feature go out without looking at it myself, and what I want a team looking at is whether it works the way they intended. An expected result is that intention, written down so someone else can ask the same question.
Three Test Case Examples, Rewritten
Each example starts from a first draft that reads fine to its author and fails the stranger test. The products, accounts and prices are invented.
Login: Say What State the Account Is In
| Field | First draft | Rewritten |
|---|---|---|
| Title | Verify login | A verified account signs in and lands on its dashboard |
| Preconditions | None | Account [email protected] (name: Dana) exists, is verified and is unlocked. The browser is signed out. |
| Data | Valid credentials | Email [email protected] and its password from the team’s test data sheet |
| Steps | Log in | 1. Open the sign-in page 2. Enter the email 3. Enter the password 4. Select Sign in |
| Expected result | User logs in successfully | The dashboard opens with “Welcome back, Dana” in the heading |
“Successfully” was a picture in the writer’s head. The rewrite puts it on the page, and it names the account state, because a runner who borrows the account locked by last week’s lockout case fails it while the app does exactly what it should. The lockout, a wrong password and an unverified account each get a case of their own.
Checkout: Work Out the Number Before You Run It
| Field | First draft | Rewritten |
|---|---|---|
| Title | Check free shipping | An order of exactly $50.00 ships free |
| Preconditions | Items in cart | Signed in as [email protected], with an empty cart and a US address saved |
| Data | Any products | Two Canvas Totes at $25.00 each |
| Steps | Go to checkout | 1. Open the Canvas Tote page 2. Set the quantity to 2 3. Select Add to cart 4. Open the cart 5. Select Checkout |
| Expected result | Shipping is correct | Subtotal $50.00, shipping $0.00, total $50.00 |
The rewritten case catches the bug from the intro. Its two siblings change only the cart, named in each one’s Data field: one tote and a $24.99 notebook (subtotal $49.99, shipping $6.00, total $55.99), and two totes and a $30.00 water bottle (subtotal $80.00), which ships free. Every number came from the rule, worked out before anyone opened the app.
Search: Seed the Data So Relevant Becomes a List
| Field | First draft | Rewritten |
|---|---|---|
| Title | Search returns relevant results | Searching “trail” lists the three seeded trail products |
| Preconditions | None | Catalog loaded from the search-trail data set: Trail Runner, Trail Jacket, Trail Map (out of stock) and Trial Pack |
| Data | A common product name | The search term “trail” |
| Steps | Search for a product | 1. Select the search box 2. Type “trail” 3. Press Enter |
| Expected result | Relevant results appear | Three results: Trail Runner, Trail Jacket and Trail Map, with Trail Map marked Out of stock. Trial Pack isn’t listed. |
“Relevant” is an opinion, and two runners will hold different ones. On a seeded catalog, relevance turns into a list you can compare line by line. Run the same case against the live catalog and it rots the first time a merchandiser adds a product with “trail” in its name.
Five Mistakes That Split the Verdict
The first two make a case ambiguous, so two runners disagree. The other three make it flaky, so one runner gets a different answer on a different day.
- An expected result that needs an opinion. “Loads quickly” and “looks right” pass for one runner and fail for the next. Write the value, the text or the count.
- Data left to the runner’s choice. “Any products” or “a valid user” lets each runner pick, and each pick tests something different. The $60 order in the intro passed a case meant for $50.00. Name the values, or the data set that creates them.
- Data that expires. A coupon with an end date, an account wiped by the weekly environment reset, a delivery date typed as 12/15 that is in the past by January. The case passes until the data goes, then fails for a reason that isn’t a bug. Point it at a data set that creates fresh values, or add a setup step that does.
- A case that needs the one before it. Case 14 edits the order that case 13 placed. Run 14 on its own, or after 13 fails, and it fails too. Each case sets up its own state.
- A result tied to the clock. “The delivery date shows Friday” holds for orders placed on some days and not others. State the result against a precondition, such as three business days after the order date, or fix the date in the preconditions.
Where Test Cases Live and Who Runs Them
A spreadsheet holds the six fields fine for a few dozen cases. Past that, test management tools such as TestRail and Xray record each run separately from the cases it ran, which keeps run data out of the case for you.
I’m seeing some teams go the other way. The more experimental ones leave their test management tool for a lightweight sheet or tool they built themselves and wired into the rest of their stack, because the old tool wasn’t built for the way they test with AI. It may say more about the forward-looking teams we work with than about the market, and either setup holds as long as run results stay out of the case.
Write every case so a person or a script could run it, and you can make the manual vs automated testing decision one case at a time, later. When a case moves into test automation, the four fields a runner uses each have somewhere to go:
| In the case | In an automated test |
|---|---|
| Preconditions | Setup code that creates the account and fills the cart |
| Test data | A fixture file or a seeding script |
| Steps | Actions against the page or the app |
| Expected result | An assertion |
An expected result that needs an opinion has no assertion to become, which is one more reason to cut the opinion out before anyone automates the case. The same fields carry over when a team moves its cases into functional testing software that runs them for it.
Write the Steps in Words, and Let Pie Run Them
On our agentic testing platform, each test is written as plain-language steps plus the assertions Pie checks, so the person who owns a feature can read its expected result and say whether it’s right.
- Draft from a sentence: Describe a flow in Pie Chat, and Pie explores it, then drafts a test with an objective, the steps it plans and what it will verify. You read the draft before the test is created.
- Saved versions: Every saved edit becomes a new version of the test, and you can see which version of a test a run used.
- Bring the cases you have: If your cases sit in a TestRail, Xray, Zephyr Scale or Azure DevOps export, the free test case converter rewrites them as plain-English tests and adds a note to any case with no expected result or a vague check.
Pie takes the runs. Deciding whether an order of exactly $50.00 ships free stays with whoever owns the rule.
Write for the Person Who Covers for You
A test case is a note to someone you won’t be there to brief. Give them the state, the data and a result they can check without you.
Pick two of the cases your team runs most often and hand them to someone who has never seen them. Then compare their verdicts with yours. Which of your cases would come back with a different pass or fail if someone else ran it tomorrow?
See Your Test Cases as Pie Tests
Bring a few cases your team runs by hand, and see them as plain-language tests in Pie.