All resources

How to write test cases: step-by-step guide, template, and QA examples.

To write a useful test case, define the behavior you want to verify, prepare the context and data, describe observable steps and make the expected result clear. This guide shows how to apply it with login and checkout examples.

Practical template

How to write a test case in five steps.

Start with a concrete situation that could fail or behave unexpectedly. Then turn that situation into a verification someone else can repeat and understand without additional context.

  1. Define the objective: what behavior, rule or risk you want to verify.
  2. Prepare preconditions and data: environment, account, permissions, configuration or needed data.
  3. Write observable steps: concrete actions, in the order they are executed.
  4. Indicate the expected result: the visible or verifiable signal that confirms the behavior.
  5. Record the result and evidence: link them with the build, observations, screenshots or defect if applicable.

This structure works as a minimum template. It is then adjusted to risk: a critical calculation may need more data and edges; a simple verification, fewer steps.

Let us start with the essentials

What is a test case?

It is a verifiable description of an expected behavior. It gives the team a common starting point: what condition must be met, what data will be used to test it, and how to recognize a correct or incorrect result.

A good case does not aim to document every click out of habit. It aims for someone else to execute the verification, interpret a failure and relate it to the delivery being evaluated.

Before opening a spreadsheet or tool

A requirement is not always a case. First you need to find the condition worth testing.

A user story may say "as a customer, I want to apply a coupon." That does not yet indicate what should be tested. The conditions appear when asking what rules change the result: validity, product eligibility, discount accumulation, currency, permissions or error messages.

Scenario

The business situation: apply a coupon during a purchase.

Test condition

The verifiable rule: a valid coupon applies a discount once to an eligible product.

Test case

The data, steps and expected result that allow testing that condition.

Risk

The consequence of failure: overcharging, allowing an invalid discount or blocking a purchase.

The minimum structure

Enough so the result preserves context.

Objective

The behavior or risk to validate. "The user can log in with valid credentials" is clearer than "test login".

Preconditions and data

Environment, account, permissions and needed data. They prevent a test from depending on invisible assumptions.

Steps and expected result

The action and the signal that confirms the behavior. The expected result must be observable.

Evidence and link

When executing, the result is associated with a build, observations, attachments or defect when applicable.

Designing coverage is not duplicating steps

Look for edges, rules and combinations before multiplying cases.

The most valuable cases usually appear where a rule changes: a limit amount, the last validity day, a missing permission, an empty field or a combination of two conditions. Instead of writing ten almost identical variants, ask what new behavior each one brings.

Example · Discount field

The rule is "accept coupons of 6 to 10 alphanumeric characters".

  1. Test a valid 6-character coupon.
  2. Test a 5-character one to check the lower limit.
  3. Test an 11-character one to check the upper limit.
  4. Test disallowed characters and an expired coupon.

The idea: each case represents a different condition; it is not a repetition of the same path with another name.

Fictional examples

Two cases showing the difference between an idea and an executable test.

TC-LOGIN-001 · Login with valid credentials

Objective: verify that an active account accesses the panel.

  1. Open the login screen in QA environment.
  2. Enter the email and password of an active test account.
  3. Submit the form.

Expected result: the user reaches the panel, their identity is displayed and no error message appears.

TC-CHECKOUT-004 · Valid coupon at checkout

Objective: verify the discount modifies the total before payment.

  1. Add an eligible product to cart.
  2. Enter a valid test coupon.
  3. Continue to the purchase summary.

Expected result: the discount is applied once, the total is recalculated and the summary reports the benefit in a clear way.

Not everything runs with the same urgency

Prioritize by impact and probability, not by the order cases were written.

If time is limited, a team needs to know what cannot go unreviewed. Payment flow, access, permissions or data loss cases usually have higher impact than a secondary visual preference. Criticality does not replace coverage, but it helps order a real execution.

First: critical path

Access, purchase, creation, saving or actions that block the user's main objective.

Next: business rules

Discounts, limits, permissions, calculations and conditions that can produce incorrect decisions.

Then: affected regression

Paths neighboring the change that could break due to a shared dependency.

Finally: exploration

Time to investigate unexpected behaviors, usability and risks the script does not anticipate.

Common mistakes

When a case does not help investigate or decide.

  • Writing "verify that it works" without defining the expected signal.
  • Omitting environment and test data in flows that depend on them.
  • Turning each case into an extensive manual without explaining the risk it covers.
  • Recording a failure without relating it to the corresponding build, evidence and defect.

The case does not end when approved

The quality of a library depends on its maintenance, not its quantity.

When a rule changes, the case must be reviewed together with its data and expected result. If two cases cover exactly the same thing, they should be consolidated. If a case fails because the product changed in a valid way, it is not a "false positive" to ignore: it is a signal that the documented expectation is outdated.

During execution, distinguish the expected result from the actual result. "Failed" identifies the status; the observation, the affected step and the evidence explain the fact. That difference is what allows someone else to review the result without reconstructing the history.

The next step

A case gains operational value when connected to an execution and a delivery.

Treseko organizes projects, builds, suites, cases, results and evidence in a single chain so the release conversation does not have to be reconstructed from scratch.

Download the test case template Discover the test case management solutionSee the Treseko QA model