QA Interview Hub · Knowledge base · Quizzes · Українська

QA Fundamentals › Test documentation

What does a good test case consist of?

A good test case consists of a title, preconditions, inputs, steps, expected results and postconditions. It is concrete enough that another person can run it and reach the same result. Data and expectations are written as exact values, not as “a large amount” or “works correctly”. One case checks one result, and its title says what is checked. A priority and a link to the requirement help pick cases for regression.

QA Fundamentals · Test documentation

A colleague ran your test case and marked Pass, while you knew there was a bug there. What is wrong with the case?

The case “Transfer over the limit” meant the amount 10,001 UAH. The steps said “enter a large amount”. A colleague entered 500, got no error and honestly marked Pass. A test case is not a note to yourself but a way to hand a check to another person, or to yourself half a year later. Below: what fields it consists of, which hole each one closes and what a weak and a strong version look like.

How it works and why. In ISTQB a test case is a set of preconditions, inputs, actions (where applicable), expected results and postconditions. ISTQB separately defines a test procedure, a sequence of cases in execution order. The fields are not bureaucracy: each answers a question that every executor would otherwise answer in their own way.

A case field and what breaks without it

ID and titlecannot find it orsee why it existsPreconditionsthe system statecannot be recreatedSteps and dataeach executor goestheir own wayExpectedPass means somethingdifferent to each personPostconditionsthe next case breakson leftoversPriority,requirementorder and coveragestay invisible
Figure 1. Expected result is highlighted: the weak spot of most cases. Without it a case describes actions, not a check.

Worked example: from weak to strong. A weak case (written when “everything is obvious”):

Title:     Check the transfer
Steps:     1. Open the transfer
           2. Enter data
           3. Check that everything works
Expected:  The transfer works correctly

What is wrong here: no preconditions, so the limit and balance are unknown; “enter data” does not say which; “everything works” and “correctly” are read differently by everyone; the title does not say what is checked. The same case, ready to hand to anyone:

ID:          TC-PAY-014
Title:       A transfer that exactly exhausts the daily limit
Preconditions: User is logged in; daily limit 10,000 UAH;
             9,000 UAH already transferred today; balance 5,000 UAH;
             fee 0.5%
Steps:
  1. Open "Transfer to card"
  2. Enter a valid recipient card number
  3. Enter the amount 1,000.00
  4. Confirm the transfer
Expected:    Transfer succeeds; remaining limit 0.00;
             balance 3,995.00 (1,000 + fee 5.00)
Postconditions: Reset the user's limit counter
Priority:    High     Requirement: REQ-LIM-03     Type: positive

Title and expected result

Typical

Check the transfer

Expected: “the transfer works correctly”. It does not say what correct means: which remaining limit, which balance, which message.

Better

A transfer that exactly exhausts the daily limit

Expected: the transfer succeeds, remaining limit 0.00, balance 3,995.00. Every number can be matched with the screen or the database.

Figure 2. The same scenario: the difference is whether the result can be checked without guessing.

Limits and alternatives. ISTQB distinguishes high-level cases (no concrete values, the executor supplies them) and low-level ones (concrete data and expectations). High-level ones are faster to write and live longer but need an experienced executor; low-level ones are repeatable but costlier to maintain. The same content in BDD is written as Given-When-Then: Given is the preconditions, When the steps, Then the expected result. An automated test is a case too, only in code, and the fields turn into setup, actions and assertions. “One case, one check” means one outcome, not one assert: several checks of one outcome (remaining limit and balance) are fine.

Common mistakes.

  • The value “any valid one”: the executor takes the first that comes to mind and the boundary is never checked. Write the data explicitly.
  • Expectations hidden in the steps (“enter the amount and check that all is well”): the result is lost among actions.
  • Two outcomes in one case for no reason: when it fails it is unclear what broke.
  • Postconditions forgotten: the case left the limit exhausted and the next one fails without a defect.

Check yourself

A “Reset password” case has the step “open the email and follow the link”. The email never came and a colleague recorded Fail. Why might that be a wrong result?

Answer

The preconditions do not say that the test user’s mailbox is available and mail works. If the mailbox is down, it is not a reset defect but a blocked case. Preconditions separate “the product is broken” from “the conditions were not there”.

A case “Create an order, pay and cancel” fails at the third step. What does that say about its structure?

Answer

It has several outcomes, so it is unclear what broke and which steps even ran. Three cases with their own preconditions are better, keeping the end-to-end scenario as a separate one on purpose.

In an interview. Junior: A good test case has a clear title, preconditions, short steps with data and a concrete expected result, plus priority and a link to a requirement. Middle/Senior: My criterion: another tester goes through the case without questions and records the same result. So I write data and expectations as numbers, keep preconditions separate, and one case checks one outcome. Where the values do not matter I write a high-level case, where they do, a low-level one.

More articles in this chapter