Skip to content

Computer Science · Ch 4 — Introduction to Problem Solving

Testing and Debugging

4.2.4

Testing and Debugging

Writing the program is not the end of the journey — the program must now be tested against various parameters to confirm it truly solves the problem. A program passes muster only when it:

  • meets the requirements of the user,
  • responds within the expected time, and
  • generates correct output for all possible inputs.

Kinds of errors

Two kinds of failure show up during testing:

  • Syntactical errors — mistakes in the grammar of the programming language itself. When these are present, the program produces no output at all; it cannot even run.
  • Logical errors — the program runs, but the output it generates is incorrect. If wrong output appears, the program must be examined for flaws in its logic.

Standardised testing in the software industry

For complex applications, the software industry does not test casually — it follows standardised testing methods, applied in stages:

  • Unit (component) testing — each individual piece is tested on its own.
  • Integration testing — the pieces are tested working together.
  • System testing — the complete system is tested as a whole.
  • Acceptance testing — the software is checked against what the user/business actually asked for.

The purpose of this discipline is to ensure the software meets all the business and technical requirements and works as expected.

Debugging: the test–fix cycle

Errors or defects uncovered in the testing phases are debugged — that is, rectified — and the program is then tested again. This loop of test → find defects → fix → re-test continues until all the errors have been removed from the program.

Maintenance after delivery …