Question

In boundary analysis testing, some authors suggest testing MIN-1, MIN, MIN+1 (and the same for MAX).

Also for 1-100 range (if A>=1 && A<=100), test cases would be: 0,1,2 and 99,100,101.

I do not see the point - if 100 works, then 99 must work too (in my opinion but this is why I ask).

Was it helpful?

Solution

Lets assume you are testing a class "interval", representing intervals of natural numbers:

 var interval= new Interval(1,100);

Now your first two tests are "green":

AssertIsTrue(interval.Contains(100))
AssertIsFalse(interval.Contains(101))

and you are confident the author made no "off-by-one-error".

Unfortunately, the implementation looks like this

Contains(x)
{
    return (x>= beginRange && x == endRange);
   // above line has a typo, "==" should have been be "<="
}

So you were better off to add another test at first hand,

 AssertIsTrue(interval.Contains(99));

which fails, revealing the bug missed by the first two tests.

Or to be more general: off-by-one errors do not always manifest themselves by mixing up "<" and "<=", there are lots of other possibilities to get such things wrong, and as a tester, you are better off not to make any assumptions about how the internal implementation of a function looks like.

OTHER TIPS

In boundary analysis testing, some authors suggest testing MIN-1, MIN, MIN+1 (and the same for MAX) ... I do not see the point

The point is that your code is expected to fail for values outside the permitted range and that's what you're testing with these "extra" cases.
Not every test should pass; you need to test for [some] things that you would expect to fail - and correct the problem if/when they don't.

Licensed under: CC-BY-SA with attribution
scroll top