GCSE Revision

Testing

Testing as you build

Testing checks whether a program behaves as intended and helps find faults. Iterative testing happens throughout development: test a small part, fix problems, then add the next part. Final testing checks the completed program against its requirements and test plan.

A syntax error breaks the language's rules, such as forgetting Python's colon after if age >= 11. A logic error lets the program run but gives a wrong result, such as using age > 11 when age 11 should also be accepted. Testing with expected results helps reveal both kinds of error.

Key terms

Test data types

Suppose a program accepts an age from 11 to 16 inclusive. Choose test data to check typical and difficult cases:

  • Normal: 14 is an ordinary allowed value; expect it to be accepted.
  • Boundary: 11 and 16 are the lowest and highest allowed values; expect both to be accepted.
  • Invalid: 10 and 17 are numbers outside the allowed range; expect them to be rejected.
  • Erroneous: four is the wrong type for an age; expect the program to report the problem and ask again, not crash.

Using several kinds of data is more useful than trying only a typical value.

Key terms

Test plan: age checker

A test plan records the input for each test and the result that should happen. This complete plan checks the age rule from 11 to 16 inclusive:

TestDataTypeExpected result
114NormalAccept; report valid age
211Boundary: minimumAccept; report valid age
316Boundary: maximumAccept; report valid age
410Invalid: below rangeReject; ask for an age from 11 to 16
517Invalid: above rangeReject; ask for an age from 11 to 16
6fourErroneous: not numericExplain that a number is needed; ask again without crashing

When running the tests, record the actual result too and compare it with the expected result. If they differ, correct the program and repeat the tests; a change can introduce a new fault elsewhere.

Key terms

Take the quiz