CIE AS & A Level Computer Science, section 12.3 (Program testing and maintenance)
Test strategy and test plan
- A test strategy is the overall approach to testing: which methods and stages will be used, the order, who will test, and what tools are used.
- A test plan is a detailed list of the tests. It is needed so that testing is organised and complete, and results can be compared with what was expected.
Contents of a test plan
| Test number | Purpose | Test data | Expected result | Actual result | Pass or fail |
|---|
Types of test data
- Normal (valid) data: data the program should accept and process.
- Abnormal (invalid) data: data the program should reject, such as the wrong type.
- Extreme (boundary) data: the highest and lowest valid values (and the values just outside them).
Worked example
A program accepts an age from 18 to 65 inclusive.
| Test | Data | Type | Expected result |
|---|---|---|---|
| 1 | 30 | normal | accepted |
| 2 | 18 | extreme (lowest valid) | accepted |
| 3 | 65 | extreme (highest valid) | accepted |
| 4 | 17 | boundary just outside (abnormal) | rejected |
| 5 | 66 | boundary just outside (abnormal) | rejected |
| 6 | "abc" | abnormal (wrong type) | rejected |
def valid_age(age):
return isinstance(age, int) and 18 <= age <= 65
for a in [30, 18, 65, 17, 66, "abc"]:
print(a, valid_age(a)) # True True True False False False
Choosing data
Choose data that tests every path through the program and every boundary.
Common mistake: leaving out the extreme values, which is where many errors happen (such as using < instead of <=). Also, a test plan needs the expected result decided before running the test.
Exam tip: set out test data in a table with the type of data, the value and the expected result. Include the boundary values and one value just outside each boundary.
Check yourself
What are the three types of test data?
Normal, abnormal and extreme (boundary) data.
Why does a test plan record the expected result?
So that the actual result can be compared with it to see whether the test passed.
A field accepts 1 to 10. Give two extreme test values.
1 and 10 (and values just outside, 0 and 11, should be rejected).