[rspec-users] Sufficiently tested?
Andreas Plath
lists at ruby-forum.com
Tue Mar 27 08:40:06 UTC 2012
Dear Ulf,
in your fizzbuzz example a kind of simple algorithm is used (% 3 and %
5) which can be easily tested in a loop. If this loop is clearly
predictable, a test with only three levels like 3, 6, 9 is enough in my
opinion.
To extend the test from 1 to 100 in this case is a bit to much. Assuming
there are exceptions in fizzbuzz like 60 should not be "Fizzbuzz" and 89
should not be "Fizz" your loop would fail. My point is not that your
loop fails. My point is You have to create a new algorithm for your
loop, taking care of the exceptions for 60 and 89.
Keeping the thought of a loop including a special algorithm, one might
be tempted to extend the loop from 100 to lets say 1000 or even more.
I think loops an algorithms in tests can be used if they are aware of
expectations and still valid, if they can be extended. Special scenarios
like days in a month have no values > 31, so there is no reason, to
extend a loop for days of a month to more than 31. Days in a month is
commonly known thing. But other types of information can of course be
mor exceptional, like 0 kelvin = -273.15 degrees Celsius and an
algorithm testing a colder temperature would be some how out of scope.
So when an algorithm is with out exceptions valid and easily
predictable, testing of three values should be fine.
Cheers,
Andreas
--
Posted via http://www.ruby-forum.com/.
More information about the rspec-users
mailing list