Blog / How to Write Test Cases Two Testers Will Agree On
Guide

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.

FieldWhat it holdsKeep it?
IDA stable handle, such as SHIP-014, that bug reports and runs point atYes, and never reuse one
TitleThe behavior, in one sentenceYes. It’s how the next person spots a duplicate
PreconditionsThe state of the account, the app and the environment before step oneYes
Test dataExact values, or the name of a data set that creates themYes
StepsOne action each, in the words on the screenYes
Expected resultWhat the runner should see, with the valueYes. Verdicts split here
PriorityHow much a failure mattersOnly if someone revisits it each release
Actual result, status, tester, dateWhat happened on one runMove 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.

  1. 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.
  2. 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.
  3. 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.
  4. 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.
  5. 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.
  6. 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

FieldFirst draftRewritten
TitleVerify loginA verified account signs in and lands on its dashboard
PreconditionsNoneAccount [email protected] (name: Dana) exists, is verified and is unlocked. The browser is signed out.
DataValid credentialsEmail [email protected] and its password from the team’s test data sheet
StepsLog in1. Open the sign-in page
2. Enter the email
3. Enter the password
4. Select Sign in
Expected resultUser logs in successfullyThe 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

FieldFirst draftRewritten
TitleCheck free shippingAn order of exactly $50.00 ships free
PreconditionsItems in cartSigned in as [email protected], with an empty cart and a US address saved
DataAny productsTwo Canvas Totes at $25.00 each
StepsGo to checkout1. Open the Canvas Tote page
2. Set the quantity to 2
3. Select Add to cart
4. Open the cart
5. Select Checkout
Expected resultShipping is correctSubtotal $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

FieldFirst draftRewritten
TitleSearch returns relevant resultsSearching “trail” lists the three seeded trail products
PreconditionsNoneCatalog loaded from the search-trail data set: Trail Runner, Trail Jacket, Trail Map (out of stock) and Trial Pack
DataA common product nameThe search term “trail”
StepsSearch for a product1. Select the search box
2. Type “trail”
3. Press Enter
Expected resultRelevant results appearThree 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.

  1. 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.
  2. 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.
  3. 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.
  4. 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.
  5. 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 caseIn an automated test
PreconditionsSetup code that creates the account and fills the cart
Test dataA fixture file or a seeding script
StepsActions against the page or the app
Expected resultAn 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.

Frequently Asked Questions

A login case is the classic one. Its preconditions say a verified account exists and the browser is signed out. Its steps enter that account's email and password and select Sign in. Its expected result names what appears, such as the dashboard with the user's name in the heading.
Start from one behavior you could prove false, such as an order of exactly $50.00 shipping free. Write the preconditions and the exact data, then one action per step. End with a result someone can check. Then ask a teammate who didn't write it to run it and compare verdicts.
A spreadsheet works for a few dozen cases. Past that, test management tools such as TestRail and Xray record each run separately from the cases it ran. Keep the actual result and the status in that run record, so neither one overwrites the case.
Yes. Give it a requirement and it will draft titles, steps and expected results in seconds. The expected results are the weak spot, because the model fills gaps in the requirement with guesses. Have someone who knows the feature confirm each one before the case joins your suite.
A test scenario names something to test, such as free shipping at checkout. A test case is one exact check inside it, with its own preconditions, data, steps and expected result. One scenario usually needs several cases, one for each input that should behave differently.
Write one for each behavior, then one for each input that should change the outcome. Free shipping needs an order just under the line, one exactly on it and one well above it. Stop when a new case would only repeat an existing one with different values.
Yes. Each Pie test is plain-language steps plus the assertions it checks, so a feature's owner can follow every line. You can draft one from a sentence in Pie Chat. Every saved edit becomes a new version of the test, and you can see which version of a test a run used.
Jinoo Jain
Jinoo Jain
CPO & Co-founder at Pie

Spent a decade in B2B SaaS sales before building Pie. Now obsessed with helping engineering teams ship without the fear of breaking things. LinkedIn →