Testing
Testing is an important process required to find and remove errors from your code. Failure to properly test code before releasing it can result in errors. Depending on the use of your software these errors could be catastrophic,
Testing
Testing is the process of finding and removing errors from your code. Spotting and removing syntax errors is easy to spot as your interpreter will usually point you in the right direction by telling you that the are there.
Finding Logical errors on the other hand can be a lot trickier and can end up being a very time consuming process. It is vital that proper testing is completed before code is published. Can you imaging the consequences air plane auto pilot or life support machine software had bugs in it!
Finding Logical errors on the other hand can be a lot trickier and can end up being a very time consuming process. It is vital that proper testing is completed before code is published. Can you imaging the consequences air plane auto pilot or life support machine software had bugs in it!
What we are testing for?
We are generally looking to see if our code works in the way that it is expected to.
Does it accept or reject data that it is supposed to
Does it crash unexpectedly
Does it produce the correct result
Are users able to enter incorrect data
Does it accept or reject data that it is supposed to
Does it crash unexpectedly
Does it produce the correct result
Are users able to enter incorrect data
Test Data
Test data is made up data that you choose to enter into your program. The test data should fall into three main categories:
- Valid Data
- Invalid Data
- Boundary Data
Valid data
This data should be data that is accepted by the program. This data should not cause any errors and should allow the program to process normally.
Example 1 - If a program asks a user to enter a number less than 50. (X < 50)
A Valid Test data would be 7 (Or any number between 0 and 49)
Example 2 - If a program asks a user to choose a password that is more than 8 characters long
A valid test data would be "TopSecret123" (Or any other password with 9 or more characters)
Example 1 - If a program asks a user to enter a number less than 50. (X < 50)
A Valid Test data would be 7 (Or any number between 0 and 49)
Example 2 - If a program asks a user to choose a password that is more than 8 characters long
A valid test data would be "TopSecret123" (Or any other password with 9 or more characters)
InValid data
This data should be data that is not accepted by the program. This data should be rejected by the program. Your program should take adequate steps to reject invalid data, if it fails to reject it then errors can occur or the program can crash.
Example 1 - If a program asks a user to enter a number less than 50. (X < 50)
An Invalid Test data would be 55 (Or any number greater than 50)
Another Invalid test data would be string like"Apple" as it is not a number and should be rejected.
Example 2 - If a program asks a user to choose a password that is more than 8 characters long
An Invalid test data would be "Secret" (Or any other password with less than 9 characters)
Example 1 - If a program asks a user to enter a number less than 50. (X < 50)
An Invalid Test data would be 55 (Or any number greater than 50)
Another Invalid test data would be string like"Apple" as it is not a number and should be rejected.
Example 2 - If a program asks a user to choose a password that is more than 8 characters long
An Invalid test data would be "Secret" (Or any other password with less than 9 characters)
Boundary data
This data could be accepted or rejected by the program. The data chosen here must be on the boundary of what is acceptable data. You should test both sides of the boundary i.e. is the data accepted if it is just within the boundary and is it rejected if it is just outside.
Example 1 - If a program asks a user to enter a number greater than 40 but less than 50. (X > 40 and X < 50)
In this scenario the numbers 41 and 49 are the boundary numbers that should be accepted by the program
numbers 40 and 50 are the boundary numbers that should be rejected.
Example 1 - If a program asks a user to enter a number greater than 40 but less than 50. (X > 40 and X < 50)
In this scenario the numbers 41 and 49 are the boundary numbers that should be accepted by the program
numbers 40 and 50 are the boundary numbers that should be rejected.
Trace Tables
Once you have decided upon your test data it is a good idea to use something called a trace table, The trace table will allow you to follow through the program with your test data and identify where errors may occur. To learn more about trace tables you should visit the dedicated page. Click here
Vertical Divider