I don't understand at all. Why would the tests still pass?
An example:
int fun(int a, int b) {
if (a >= b) {
return 1;
}
return 0;
}
now you could test this by saying:
fun(4,3) should give '1' as the output
and
fun(3,4) should give '0' as the output
But you'd miss to test for equality, with fun(3,3) which should *also* give 1 as output
So you'd need an extra test for the '=' part of the condition. Replacing '>=' with '>' will still pass the first two tests, so if you forgot about the third you will not even realize something is wrong until your code starts breaking in mysterious ways.Unit tests have to be just as good as the code you wrote.
I'm not arguing against unit tests, they definitely have a time and a place. I'm just not convinced that they are an easy and instant cure for all your hardest bugs.
Not a fan of unit testing my self. I feel the approach lacking.