Menu

Testing

Purpose of Testing

Testing means running a program, or part of a program, with data you have chosen, to check that it works. You pick the data on purpose so that the test has a point: you already know what the program should do with it.

The main purpose of testing is to find errors so that they can be fixed. A program with errors in it will cause problems for whoever uses it, so the sooner the errors are found, the better.

What testing checks

  • It does the job it was written for. The program should do what it is intended to do and meet the user's requirements. If a school library program is meant to show when a book is overdue, testing confirms that it does.
  • The output is correct. You give the program known data and check the result is what it should be. A program that converts minutes into hours should turn 150 minutes into 2 hours 30 minutes, not 2 hours 50 minutes.
  • It copes with likely inputs. A program should keep working with the kinds of data it will really receive, and stay sensible when it gets unexpected input instead of crashing. A program that survives bad input and carries on is called robust.
  • It is usable. Testing can also look at usability and user experience, such as whether the messages on screen make sense, and at performance, such as how quickly the program responds.

Why test before release?

Testing happens before the program is released so that the errors found can be fixed while there is still time to change the code. A test that fails is useful: it proves the program does not yet work as intended and gives you a place to start looking. You can then correct the code and run the same test again.

One thing testing cannot do is prove that a program has no errors at all. You can only try the data you think of, and an untested path through the program may still hide a problem. Testing finds errors so they can be fixed; it does not guarantee a perfect program.

Practise this