Testing

Once the program has been written it is necessary to test the program for any errors. The testing stage can take quite a long time as the program must work under most conditions. ​

There are three types of testing: ​

Normal (N) – Data the program should expect to handle. ​

Extreme (L) – Data at the limits of what the program should handle. ​

Exceptional (E) – Data which the program has not

The aim of testing is to prevent software failure. Using normal, exceptional and extreme test data as part of a test plan will reduce the prevalence of syntax, logic and execution to errors in code.

Test Tables

Test tables are used to provide a structure to testing.

Programmers will often create a table with a selection of normal, extreme and exceptional data that they intend to use during testing. The table will include:

  • a column for the expected result
  • a column for what actually happens when the program runs

The programmer will refer to the functional requirements created at the analysis phase to act as a reminder of the inputs that the program is expected to handle.

What data to test

A test table should include:

  • at least two items of normal data
  • at least two items of exceptional data]
  • both extreme values if testing a range of numbers

It is also good practice to test the values immediately out with the accepted range as it is common to find errors that occur because of a selection statement that makes use of incorrect logical operators.

Syntax, Execution and Logic errors

There are three types of error that you need to understand.

Syntax error

This is an error in the spelling or grammar used when coding. Missing a letter, character or forgetting to include inverted commas/speech marks are common examples of syntax errors. A syntax error will be identified by an interpreter as it will be unable to convert the source code into machine code.

Execution error

Sometimes called a runtime error, execution errors only become evident during run time. An execution error occurs when a program is asked to do something that it cannot, resulting in a ‘crash’. The widely used example of a run time error is asking a program to divide by 0.

Logic error

An error in the logic of the code such as using ˂ instead of ˃ or AND instead of OR. The program will execute the code but will produce unexpected results. Logic errors are usually resolved by carrying out a dry run, using a trace table or setting breakpoints to help identify the section of code that contains the logic error.