Objectives: Students should be able to —
- 1 Define what is meant by test data and explain its purpose in testing a program.
- 2 Describe and distinguish between normal, abnormal (erroneous) and boundary (extreme) test data.
- 3 Select suitable normal, abnormal and boundary test data for a given input range.
- 4 Construct test data tables for programs with one or more inputs (price, quantity, hours, rate, etc.).
- 5 Identify suitable test data for programs that use selection (IF statements) and password validation routines.
- 6 Explain why it is important to use a range of different types of test data when testing a program.
What is Test Data? — Types of Test Data
(a) Describe what is meant by test data:
Test data is data that has been specifically created and selected for testing a program. It is used to check whether a computer system works correctly and to identify any errors (bugs) in the code before the program is released for real use.
(b) Difference between normal, abnormal and boundary test data:
| Type of test data | Description | Example (for an input that must be a number between 1 and 10) |
|---|---|---|
| Normal (Valid) | Data that is expected (valid) and should be accepted by the system. It falls within the allowed range and is in the correct format. | 5 |
| Abnormal / Erroneous (Invalid) | Data that is unexpected (invalid) and should be rejected by the system. It is outside the allowed range, the wrong data type, or in the wrong format. | 11, 0, -5, "hello" |
| Boundary / Extreme | Data that is on the edge or limit of what is allowed. Used to find off-by-one errors in the logic at the boundaries of selection statements. | 1, 10, 0.99, 10.01 |
(c) Three reasons why test data is used:
- To ensure the program works as expected for valid input.
- To find errors (bugs) in the code before the program is released.
- To check robustness — to ensure the program handles invalid input safely without crashing.
Selecting Test Data for Simple Inputs
(a) Example of normal data:
Any whole number between 11 and 19, e.g. 15. (It is strictly inside the valid range — not on the boundary.)
(b) Example of abnormal data:
Any value outside the valid range or of the wrong type, e.g. 9, 21, 15.5 (non-integer), or "ten" (wrong data type). All these should be rejected.
(c) Example of boundary data:
The two values that sit exactly on the edges of the valid range — 10 and 20. Both should be accepted. (The values just outside — 9 and 21 — are also useful boundary tests that should be rejected.)
(a) Two items of normal data:
Any two values strictly inside the valid range, e.g. 20 and 30. (Both should be accepted.)
(b) Two items of abnormal data:
Any values clearly outside the valid range or of the wrong type, e.g. 10 (below 16), 70 (above 65), -5, or "ten" (wrong data type). (All should be rejected.)
(c) Four items of boundary data:
The two values on the edges of the valid range and the two values immediately outside them — 15 (rejected), 16 (accepted), 65 (accepted), 66 (rejected). Testing both sides of the boundary confirms whether < vs <= has been written correctly.
| Test data | Type of data | Reason |
|---|---|---|
| 50 | Normal | Strictly inside the valid range (0–100). |
| -1 | Abnormal | Below the lower limit; should be rejected. |
| 0 | Boundary | Lower limit of the valid range. |
| 101 | Abnormal | Above the upper limit; should be rejected. |
| 100 | Boundary | Upper limit of the valid range. |
| abc | Abnormal | Wrong data type — text instead of a number. |
Test Data Tables for Programs
| Test data | Price | Quantity | Expected result | Reason for choice |
|---|---|---|---|---|
| Normal | 10.00 | 5 | 50.00 | Typical, valid values that the program should accept. |
| Abnormal | -5.00 | 2 | Error message | Negative value for price; should be rejected. |
| Extreme | 0.01 | 1 | 0.01 | Lowest possible valid values; tests small number handling. |
| Boundary | 999.99 | 100 | 99999.00 | Highest possible valid values; tests the upper limit. |
Accept any sensible values in the Reason for choice column. The key idea is that Normal = typical valid, Abnormal = clearly invalid, Extreme = very large/small but still valid, and Boundary = values sitting on the edges of the valid range.
| Input variable | Normal data | Abnormal (erroneous) data | Boundary (extreme) data |
|---|---|---|---|
| Hours worked | 20, 40 | -1, 65, 10.5 | 0, 60 |
| Hourly rate | 10.50, 15.00 | 0, -5, "ten" | 0.01 (just above 0) |
| Tax rate | 20, 30 | -1, 51, 25.5 | 0, 50 |
(a) Test data table:
| Type of data | Value entered | Expected result |
|---|---|---|
| Normal | 5 | Accepted |
| Abnormal | 25, -1, "ten" | Rejected |
| Boundary | 20 | Accepted |
| Boundary | 21 | Rejected |
(b) Why both sides of the boundary must be tested:
Testing both 20 (accepted) and 21 (rejected) confirms that the programmer has used <= rather than < in the selection statement. If only one side is tested, an off-by-one error at the limit may go unnoticed — the program might wrongly accept 21 tickets or wrongly reject 20.
Test Data for Selection Statements & Validation Routines
(a) Range of valid numbers accepted:
Any number greater than 0 and less than or equal to 100 — i.e. 0 < Number ≤ 100. The lower bound 0 is excluded (because the test is > 0), but the upper bound 100 is included (because the test is <= 100).
(b) Example of abnormal data:
Any non-numeric value such as "hello" or "abc". The program would crash or produce an unexpected result because the input cannot be compared with a number.
(c) Boundary data that produces "Valid":
100 — the upper boundary, which satisfies Number <= 100. (The value 0.01, just above the lower limit, is also a valid boundary test.)
(d) Boundary data that produces "Invalid":
0 — the lower boundary, which fails the test Number > 0. (The value 101, just above the upper limit, is also an invalid boundary test.)
(a) Boundary test data:
Any value that sits on the length limit or just outside it, e.g.:
- Pass1234 — exactly 8 characters (boundary, accepted).
- Pass123 — 7 characters, one short (boundary, rejected).
- Pass12345 — 9 characters, one long (boundary, rejected).
(b) Test data table:
| Test description | Input data | Expected output |
|---|---|---|
| Valid password | Pass1234 | Valid |
| Too short | Pass123 | Invalid |
| Too long | Pass12345 | Invalid |
| Contains symbol | Pass@234 | Invalid |
| Correct length, invalid char | Pass 1234 | Invalid |
Why Use Different Types of Test Data
- Normal data confirms that the program works correctly under typical conditions and produces the expected output for valid input.
- Abnormal data checks the program's robustness — to ensure it does not crash when invalid data is entered, that suitable error messages are displayed, and that the validation checks work correctly.
- Boundary data catches off-by-one errors at the edges of selection statements (e.g. using < instead of <=). Errors most often occur at the limits of valid ranges, so this is where testing is most valuable.
- Using a combination of all three types gives confidence that the program is reliable for every kind of input the user could possibly enter.
| Test data | Inputs (A, B, C) | Reason for choice |
|---|---|---|
| Normal | 25, 50, 75 | Typical valid values; expected output 75. |
| Normal (order) | 75, 50, 25 | Largest value entered first — checks the algorithm does not just pick the last entered value. |
| Normal (order) | 25, 75, 50 | Largest value in the middle — checks the algorithm finds the maximum in any position. |
| Boundary | 0, 0, 0 | All values equal to the lower limit; tests the equal-values case. |
| Boundary | 1000, 1000, 1000 | All values equal to the upper limit. |
| Boundary | 0, 500, 1000 | Mix of lower limit, mid value and upper limit. |
| Abnormal | -5, 50, 75 | Negative value — should be rejected with an error message. |
| Abnormal | 25, 50, "abc" | Wrong data type — should be rejected. |
(a) Two sets of boundary test data:
- Set 1: Age 15 ($5) and age 16 ($10) — the boundary between the Child and Adult ticket prices.
- Set 2: Age 59 ($10) and age 60 ($7) — the boundary between the Adult and Senior ticket prices.
Each pair tests both sides of the boundary — one value that should fall into one price band, and the value immediately next to it that should fall into the next price band.
(b) Why boundary data is important:
The ticket price changes at the boundaries 16 and 60. If the programmer wrote age > 16 instead of age >= 16, a 16-year-old would be charged the child price ($5) instead of the adult price ($10). Only boundary testing will catch this kind of off-by-one error — normal data such as age 25 would still produce the correct answer even if the comparison operator were wrong.
Revision: Statements and Key Computing Terms
| Statement | Key Term |
|---|---|
| Data that has been specifically created and selected for testing a program. | Test data |
| Data that is expected (valid) and should be accepted by the program; it lies within the allowed range and is in the correct format. | Normal (Valid) test data |
| Data that is unexpected (invalid) and should be rejected by the program; it lies outside the allowed range or is of the wrong data type. | Abnormal / Erroneous test data |
| Data that sits on the edge or limit of what is allowed; used to check that the comparison operators in selection statements are correct. | Boundary / Extreme test data |
| A common logic error caused by writing < instead of <= (or > instead of >=), so the program wrongly accepts or rejects a value on the boundary. | Off-by-one error |
| The reason why a programmer cannot rely on normal test data alone — it never checks validation rules or boundary limits. | Robustness testing |
| The lowest and highest values that the program should accept. | Lower / Upper limit (bound) |
| The principle of changing only one input at a time so that any fault can be traced to a single cause. | Independent variable testing |
| Type of test data used to test very large or very small (but still valid) values. | Extreme test data |
| A test plan that records, for each test value: the type of data, the input value, the expected result and the reason for the choice. | Test data table |
| Testing both the value just inside and the value just outside the valid range. | Both sides of the boundary |
| The expected program behaviour when abnormal data is entered — an appropriate message should be displayed and the user should be asked to re-enter. | Error message (validation) |