GoalChoose normal, invalid and extreme test data for a program that accepts a range of values, and say how boundary data differs.
New words
normal data · data the program should accept; it is inside the allowed rangeinvalid data · data the program should reject; it is outside the allowed rangeextreme data · the smallest and the largest values that are still acceptedboundary data · the extreme values and the first rejected value on each side of the range
Explanation
Testing means running a program with chosen data and checking that the result is what the program should do. Good testing uses different kinds of data. Normal data is accepted and sits inside the allowed range. Invalid data is rejected, so it lies outside the range. Extreme data is valid, but it sits right on the edge: it is the smallest and the largest value that is still accepted. Boundary data is similar, but it adds the nearest rejected value on each side of the range. Some values are more than one kind. For example, the smallest accepted value is normal, extreme and boundary. Not every program has every kind of test data. A program with no range, or with only two choices, may have no extreme data.
A program for lockers. A school has lockers numbered 1 to 36, and the program accepts a number only if it is from 1 to 36 inclusive, which means that 1 and 36 are allowed. The user types 12, so the program prints Locker found. The user types 37, so it prints No such locker.
Kind
Meaning
Examples for lockers 1 to 36
Normal
accepted
5, 12, 30
Invalid
rejected
0, 37, −5, 100
Extreme
smallest and largest accepted
1 and 36
Boundary
extreme values and the first rejected value on each side
0, 1, 36 and 37
The kinds of test data for the locker program. Normal data can be any accepted number. Invalid data can be any rejected number, and you choose a few. The extreme data is 1 and 36. The boundary data is 0, 1, 36 and 37: the extreme values and the rejected values next to them.
Value
Normal
Invalid
Extreme
Boundary
−1
no
yes
no
yes
0
yes
no
yes
yes
2
yes
no
no
no
3
yes
no
yes
yes
4
no
yes
no
yes
9
no
yes
no
no
One value can be several kinds. A pizza maker allows 0 to 3 extra toppings. Each row names a value. The value 0 is accepted, so it is normal, and it is also extreme and on the boundary. The value 2 is only normal. The value −1 is invalid, and it is on the boundary because it is the first rejected value. The value 9 is only invalid.
Class activity
Secret range (no computer). Think of a secret whole-number range, such as ‘accepts numbers from 8 to 20’, and write it on a card that you hide. Your partner names a number, and you reply ‘accepted’ or ‘rejected’. Your partner writes down a list of normal, invalid and extreme test numbers from your replies, and tries to guess your range using as few questions as possible. Then show the card. Which questions told your partner the most: the normal numbers or the numbers next to the edges?
Practice
1
A program accepts a seat row from 1 to 20 inclusive. Give two normal values, two invalid values, the extreme values and the boundary values.
Normal: any numbers from 1 to 20, for example 7 and 15. Invalid: any outside it, for example 0 and 25 (or −3 and 40). Extreme: 1 and 20. Boundary: 0, 1, 20 and 21.
2
A game accepts 2 to 6 players, inclusive. Say whether each value is normal, invalid or extreme. Some values are two kinds.
Value
Kind(s)
2
?
4
?
1
?
6
?
7
?
2 is normal and extreme. 4 is normal. 1 is invalid. 6 is normal and extreme. 7 is invalid.
3
A learner tests the locker program only with 3, 4 and 5. Why is this not enough?
All three values are normal data, so the tests do not show whether bad numbers are rejected. They also miss the edges, where a mistake such as using > instead of >= is most likely. The learner should add invalid data (for example 0 and 37) and the extreme data 1 and 36.
4
A program asks the user to type A, B or C to choose a snack. Which kinds of test data can be used, and which cannot? Give examples.
Normal data: A, B and C. Invalid data: for example D, 7 or a blank. Extreme data cannot be used, because there is no smallest or largest value in a list of choices.