Unable to make 100% coverage for a particular method
I cannot understand why I'm unable to make 100% coverage for a particular method. I have a static method with 2 loops and try/catch inside each of them plus a few ifs. With 2 test methods I covered 79% of the method. Frankly speaking, this is completely fine with me but out of a curiosity I wanted to reach 100%. To do that and to simulate exceptions in the loops I had to use Microsoft shims and with the help of them I saw under debugger that the execution goes through the lines which are marked "uncovered".
So, I have 3 test methods now which I know for sure go through each line of the tested method, nevertheless Unit Test Coverage still shows 79%, those catch blocks still marked "uncovered" and in the statement covered by tests in the tested method I see only two test methods. Can anybody explain why it happens and how to tell VS or dotCover or whatever is responsible for calculating the coverage that it should be 100%?
Please sign in to leave a comment.
If you debug your methods do the tests make it into the catch blocks? The tests would need to setup a scenario which causes an exception in the try block so the catch block code is executed.