Validation & Testing

Test Data Types

Always test with three types of data:

Normal Data

Typical, expected values that should work correctly.

Example: For age 0-120, test with 25, 50

Boundary Data

Values at the edges of valid ranges.

Example: For age 0-120, test with 0, 1, 119, 120

Invalid Data

Values outside acceptable range or wrong type.

Example: -5, 150, "abc", empty

Trace Tables

A systematic way to trace through code and check logic step by step.

Example: Sum numbers 1 to 3

total ← 0
FOR i ← 1 TO 3
    total ← total + i
ENDFOR
OUTPUT total
        
Step i total Condition
1-0Initial
2111 ≤ 3 ✓
3232 ≤ 3 ✓
4363 ≤ 3 ✓
5464 ≤ 3 ✗ Exit

Output: 6

Common Errors

  • Syntax errors - Spelling mistakes, missing punctuation (detected by compiler)
  • Logic errors - Program runs but gives wrong results (harder to find)
  • Runtime errors - Program crashes during execution (divide by zero)