If you have 100% test coverage and all tests pass does that mean that the code is guaranteed to be correct and writing more tests is pointless?
CodePudding user response:
It's only correct as far as the logic of your testing is correct.
I'll give the most stupid example possible...
If I for example have a class (Java):
public class Example {
public int timesTwo(int x){
return x*2;
}
}
with the following test (which you can see it being illogical and useless)
public class ExampleTest {
@Test
public void timesTwo() {
new Example().timesTwo(5);
assertTrue(true);
}
}
Most coverage tools will say that this class has been tested 100%! So no, coverage is a good indicator of what needs to be tested; but the test logic itself isn't assured.