What is Testing on the Bog?
Code has “if” statements in it. When testing you need to check that the different conditions of the if statement. Lets take the following code snippet
if input_date <= current_date:
echo 'Date not in the future'
echo 'Date in the future'
The obvious values to test is a date less than or equal to today and one in the future. Test with 2009-08-08 and 2009-08-29 would give you 100% statement and branch coverage when you get your coverage statistics from your unit tests. Well that was easy wasn't it?
“High Code Coverage” ≠ “Well tested Code”
Firstly it is “<=” so both the “<” and the “=” need to be tested separately. Also mentioned in the previous Testing on the Bog dates can be complicated beast as well.
So looking at the clear boundaries to test there are also the not so obvious ones. An example of this could be:
- Time is often stored as an integer and only formated in the interface layer, so can you put in a date which so big that it wraps the integer around and it becomes less than the current date? And the flip so negative this get confused as well?