How to write test cases for beginners comes down to one routine: take one requirement, split the possible inputs into groups, and test the edges of each group. A field that accepts a 10-digit mobile number needs about six test cases, and this article writes all six.
Most guides on how to write test cases for beginners list the parts of a test case and show one case where everything works. That is only the start. The harder question is which inputs to try, and how many cases are enough. Here is one small field, worked through.
How to write test cases for beginners: what goes in one test case?
A test case is one check that a stranger can repeat and get the same answer. ISTQB, the body behind the best-known testing certificate, defines it as a set of input values, preconditions, expected results and postconditions, written for one objective.
In a spreadsheet, that gives you these columns for each case:
- ID, such as TC-01, so a bug report can point to it.
- Precondition, what must be true before you start. For example, you are on the sign-up screen and logged out.
- Steps, short and in order.
-
Test data, the exact input. Write
9800000000, never "a valid number". - Expected result, what the screen or system must do. Write it before you run the test.
This is the usual test case format. You can keep it in Excel or Google Sheets. The format matters less than the inputs you choose.
Which inputs should a test case use?
Suppose the requirement says: "The mobile number field accepts exactly 10 digits and then sends an OTP. Anything else shows the message Enter a 10-digit mobile number."
You cannot test every possible input. Equivalence partitioning solves this. You group inputs the system should treat the same way, then test one input from each group. ISTQB's glossary says each group should be covered at least once.
For this field the groups are:
- exactly 10 digits (valid)
- fewer than 10 digits
- more than 10 digits
- an empty field
- characters that are not digits
If the system handles 9800000000 correctly, it will almost always handle 9811111111 the same way. Testing both adds a row and teaches you nothing.
What does boundary value analysis add?
Bugs collect at the edges of a group. A developer who writes length > 10 when they meant length >= 10 gets every normal number right and fails only at the edge.
Boundary value analysis means testing just below, exactly on and just above each edge. This field has a single valid length, so the edges are 9, 10 and 11 digits. A 5-digit number sits far from both edges, so it adds nothing over a 9-digit one.
What are the six test cases for the mobile number field?
This test case example is small on purpose. Each line gives the test data and the expected result. The precondition is the same for all: you are on the screen with the field, and the field is empty.
-
TC-01:
980000000(9 digits). The message appears and no OTP is sent. -
TC-02:
9800000000(10 digits). No message appears, an OTP is requested and the OTP screen opens. -
TC-03:
98000000000(11 digits). The message appears and no OTP is sent. If the field stops you typing an eleventh digit, the expected result is that the field holds 10 digits. - TC-04: the field left empty. The message appears and no OTP is sent.
-
TC-05:
98000000A0(10 characters, one letter). The message appears and no OTP is sent. -
TC-06:
+9779800000000. The requirement does not say. Do not guess the result, because this one is a question for the business analyst or developer.
TC-06 shows something beginners often miss. When the requirement is silent, a good tester writes the question down. A test case with an invented expected result only teaches the team the wrong rule.
How many test cases are enough?
The answer is a judgement, and the groups make it concrete. You have enough when every group has at least one case and every edge has a case on each side. For this field that is TC-01 to TC-05, and the question in TC-06 gets answered.
Add more cases when the requirement adds rules. If the OTP expires, that needs its own cases. If two fields depend on each other, the combinations need a decision table, which lists every combination of conditions with its expected result.
Can I use the same method for test cases for a login page?
Yes. Test cases for a login page start the same way: take each field on its own and write its groups and edges first. If the password rule says 8 to 20 characters, the edges are 7, 8, 20 and 21 characters. Then add the cases that involve both fields together, such as a correct username with a wrong password, and an empty username with a correct password.
For each login case, write what the user sees and what the system must not do. For a wrong password, the system must not open the account, and the requirement should say which message appears.
What to do next
Pick any form you use every day, such as a sign-up form or a payment screen, and find one field with a rule. Write its groups, then its edges, then the cases. Give the sheet to a friend and ask them to run it without asking you any questions. Every question they ask shows a step or an expected result that was not clear.
At Saarathi Academy in Old Baneshwor, Kathmandu, Week 2 of our software quality assurance course in Nepal covers equivalence partitioning, boundary value analysis, decision tables and state transitions on real forms. The method above is the same one, applied to more fields.
Top comments (1)
This is a clear practical introduction to equivalence classes and boundaries. The strongest lesson is TC-06: when the requirement is silent, recording an explicit question is better testing than inventing an expected result and letting that accidental assumption become product behavior.