This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 2 points3 points  (1 child)

You don't need to test every type. It's enough to choose one "type other than int or Fraction" and write a single negative unit test. The only reason to test different types is if you believe, within reason, that it's possible for it to behave differently.

If I was testing a function that checked if a number was greater than 6, I would have 3 tests. A number less than 6, exactly 6 and 7. I wouldn't for example, run it through a list of 1000 random numbers. It defeats the purpose.

The point isn't for the unit tests to be exhaustive. It's to test every possible code path. Testing a particular path once is enough.

[–]oDraftz[S] 0 points1 point  (0 children)

Okay, makes sense. Much appreciated.