Choosing test data
If you only ever run one test on your code then all you can prove is that your code works for that single case only. Programs have so many states or possible values and it is critical to do as many tests as possible. Possible tests to run fall into three categories -
- Normal data
- Extreme data
- Abnormal data
In order to explain the different types of test data we will use an example -
- IF(a>0 AND a<100) THEN
- PRINT "Value Accepted"
- ELSE
- PRINT "Value rejected"
- END IF
The test script we will use is -
Test Description |
Test data |
Expected result |
Normal test | 43 | Value accepted displayed |
Abnormal test | Wibble | Value not accepted |
Extreme test lower | 1 | Value accepted displayed |
Extreme test higher | 99 | Value accepted displayed |
Extreme test lower rejected | 0 | Value rejected displayed |
Extreme test higher rejected | 100 | Value rejected displayed |
The above code is typical of a range check validation rule. The above tests are not conclusive proof that it will work, however it is as close as we can get without spending excessive time testing. The idea is that the code accepts values between 1 and 99.
Normal tests will make sure that the standard functionality works.
Abnormal tests will ensure that if unexpected values are entered then the code will not crash. We would expect a sensible error message. This is common source of errors and abnormal values tend to crash systems. If the developer tests for abnormal values then they will spot the crash and implement code too try and prevent it.
Extreme tests test the boundary of acceptable values. In this case the values around 1 and 99. Extreme values tend to be the cause of a lot of errors. What if the above code was supposed to test 0 to 100 rather than 1 to 99? Extreme tests would reveal these problems. Logic errors tend to be in the conditions on IF statements or loops. As such testing extreme values will ensure that these logic errors are tested and avoided.