Software testing

Software testing involves testing a program under various conditions to make sure it works. Even the best programmers make mistakes, so it is important these are identified as soon as possible in the development stage so errors can be fixed.

Why test applications?

When we create computer programs we may encounter many issues. Two of these issues can be logic errors and syntax errors.

Logic errors

The program will compile and run but it will not work as the programmer intended. Consider this program to sort two numbers lowest to highest:

x = INPUT number y = INPUT number if x > y: x = y y = x PRINT x PRINT y

Can you spot the logic error? Consider the above algorithm when we assign the values x = 5 and y = 3.

x = 5 y = 3 x > y = TRUE x = y (3) y = x (3) 3 3

The program does not sort the data, rather it overwrites the data. To solve this logic error, a third variable would be required to hold the first value before they are swapped.

x = 5 y = 3 temp = 0 x > y = TRUE temp = x (5) x = y (3) y = temp (5) 3 5

Syntax error

This occurs when the translator does not understand the text we have typed. The most common type of syntax error is a variable or a command that is spelt incorrectly. For example:

Age = 16 PRINT age

During the creation and completion of digital applications, there should be regular testing. Testing checks that the application does not contain any errors and that it works as intended.