How to methodically test a program so you can be confident it actually works, rather than just 'seems to work' on the one input you tried.
Selecting appropriate test data โ always test with three categories of data:
| Data type | Purpose | Example (for an age field, valid range 0โ120) |
|---|---|---|
| Standard | Typical, everyday valid values | 25 |
| Extreme | Values right at the very edge of what's valid | 0 and 120 |
| Abnormal | Invalid values that should be rejected | -5, 'twenty', 999 |
Types of programming errors:
| Error type | Description | Example |
|---|---|---|
| Syntax error | Breaks the rules of the programming language; the program won't even compile/run | Missing a semicolon, misspelling a keyword |
| Runtime error | The program compiles and starts running, but crashes during execution | Dividing by zero, accessing an array index that doesn't exist |
| Logical error | The program runs without crashing, but produces the wrong result because the logic itself is flawed | Using + instead of - in a calculation |
Example
Trace table for a loop that sums numbers 1 to 3: i | sum 1 | 1 2 | 3 3 | 6 After the loop ends (i > 3), sum = 6 โ matches the expected result, confirming the logic is correct.
๐ก Exam Tip
Logical errors are the hardest to catch because the program runs successfully โ always test against a manually calculated expected result, not just 'does it run without crashing'.