7 Algorithm design and problem-solving

Show All Section Notes
Test yourself on Algorithm design and problem-solving 13 questions — drag-to-order, code completion, matching and multiple choice.
Start the quiz

Test Data and Test Plans

Watch this lesson Video 7.7 · 7:55 · Four kinds of test data, and how to choose values that actually prove something

1. What Is a Test Plan?

A test plan is a document that sets out what will be tested, the data that will be used, and the result that is expected before the test is run. Testing is not guessing: the expected outcome must be decided in advance, otherwise there is nothing to compare the actual outcome against.

A test plan records four things for every test: the type of test data, the data used, the expected outcome, and the reason for including that test.

2. The Four Types of Test Data

The syllabus limits test data to four types. Getting the definitions exactly right matters, because extreme and boundary data are frequently confused.

TypeDefinitionShould it be accepted?
Normal Data a user would typically enter, comfortably inside the valid range Yes
Abnormal Data the program should refuse — outside the range, or the wrong data type No — must be rejected
Extreme The largest and smallest acceptable values Yes
Boundary The largest/smallest acceptable value and the corresponding smallest/largest rejected value — a pair either side of the limit One accepted, one rejected
Extreme and boundary are not the same thing. Extreme data is a single value: the largest or smallest value that is still accepted. Boundary data is a pair of values that straddle the limit — the last one accepted and the first one rejected. Giving only the rejected value is not boundary data, and giving only one value where a pair is asked for loses the mark.
Worked distinction. A field accepts marks from 0 to 100.
Extreme data: 0 and 100 — both accepted.
Boundary data: 100 and 101 — 100 accepted, 101 rejected. Also 0 and -1 at the lower limit.

3. Worked Example: The Library Age Limit

Problem: A digital library allows users aged 5 to 18 to register. Any other age must be rejected.
Test typeInput dataExpected outcomeReason
Normal12AcceptedWell inside the valid range
Abnormal“Ten”Error messageWrong data type — string, not integer
Abnormal25RejectedCorrect type but outside the range
Extreme5AcceptedSmallest acceptable value
Extreme18AcceptedLargest acceptable value
Boundary18 and 1918 accepted, 19 rejectedTests the upper limit is set at exactly the right place
Boundary5 and 45 accepted, 4 rejectedTests the lower limit

4. Worked Example: The Discount Code

Problem: A shop application accepts a percentage discount between 1% and 50%.
Test typeInput dataExpected outcomeReason
Normal25Discount appliedTypical valid input
Abnormal-10RejectedNegative values are invalid here
Abnormal“half”RejectedWrong data type
Extreme1Discount appliedSmallest acceptable percentage
Extreme50Discount appliedLargest acceptable percentage
Boundary50 and 5150 accepted, 51 rejectedCatches a condition written as <= 51 by mistake
Why boundary testing finds real bugs. A condition written as IF Discount < 51 instead of IF Discount <= 50 behaves identically for normal data such as 25. Only the pair 50 and 51 exposes it. This is precisely why boundary data is worth including.

4b. Iterative Testing and Final Testing

Testing happens at two different scales, and the syllabus names both.

  • Iterative testing takes place during development. Each module or sub-system is tested as it is written, and the program is corrected and re-tested repeatedly — hence iterative. The point is to find a fault while the code that caused it is small and freshly written.
  • Final testing takes place after development, once all the modules are combined. The complete program is tested against the original requirements specification from the analysis stage, to confirm it does everything it was supposed to do.
Why both are needed. Iterative testing checks that each part works. Final testing checks that the parts work together, and that the finished program meets the requirements — two things no amount of module testing can establish. A program can be made entirely of modules that each pass their own tests and still fail as a whole, because modules pass data between them and nobody tested the joins.

This is also why final testing refers back to the requirements specification rather than to the code. Iterative testing asks does this module do what I intended? Final testing asks does this program do what the customer asked for? They are different questions, and only the second one can tell you the project succeeded.

5. Choosing Test Data Well

  • Cover every type — a plan with only normal data proves almost nothing
  • Include both ends of a range, not just the top
  • Include a wrong data type as well as an out-of-range value
  • State the expected outcome before running the test, not after
  • Give a reason for each test, so the plan shows why the data was chosen

6. Exam Focus

Give actual values, not descriptions. "A number that is too big" earns nothing. For a range of 5 to 18, write 25. Test data questions want data.
Abnormal data is not only out-of-range data. A value of the wrong data type — letters where a number is expected — is also abnormal, and is often the mark being looked for when the question asks for two different abnormal values.
Do not reuse the same value for two test types. If you offer 18 as extreme data, it cannot also be your only boundary answer — boundary needs the pair 18 and 19. Examiners credit each type separately.

Quick self-check

  • Define extreme data and boundary data, and state how they differ.
  • A password field accepts 8 to 12 characters. Give normal, abnormal, extreme and boundary test data.
  • Explain why testing only normal data is insufficient.
  • Give two abnormal values for a field that stores a month number, each invalid for a different reason.