Reputation: 5047
I am trying to demonstrate that 100% statement coverage does not mean much in terms of proving and testing. I cannot think of any easy example, this is my best attempt:
TestObject t = null;
if (Console.ReadLine() == "A")
{
t = new TestObject();
t.Value = 5;
}
Console.WriteLine(t.Value); //exception only when the IF statement was not run as the variable remains null.
Also when user presses "A", the statement coverage is 100%. However when anything else is pressed, the exception occurs.
Upvotes: 0
Views: 288
Reputation: 271
Steve Cornnett, from Bullseye test coverage tool, has a fantastic article called "What is wrong with Statement Coverage?"
You will find a complete analisys on why statement coverage is consider as the weakest form of coverage.
Upvotes: 0
Reputation: 289
I would say your example is the good for that purpose.
Upvotes: 1
Reputation: 4999
I think you are incorrect in your assertion. With 100% statement coverage you can be sure that you are able to devise test cases to verify ALL your code. You seem to be confusing the idea that because you are able to hit every line in your code using a unit test that it is being fully tested with one test case.
Upvotes: 0