Code coverage
-
I use the test runner of Visual Studio 2008, and I'm trying to get 100% code coverage with my unit tests in which I have almost succeeded. ;) However the last couple percent are a bitch. :sigh: I have some code in a base class that throws an error if some conditions are not met. This code is marked as only partially tested (beige). I know for a fact that this code is exercised several times during the tests. However there are some descendant classes that cannot cause condition that will lead to the execution of this particular section of code. Is this the reason I get the incomplete coverage result, and how do I cope with it?
-
I use the test runner of Visual Studio 2008, and I'm trying to get 100% code coverage with my unit tests in which I have almost succeeded. ;) However the last couple percent are a bitch. :sigh: I have some code in a base class that throws an error if some conditions are not met. This code is marked as only partially tested (beige). I know for a fact that this code is exercised several times during the tests. However there are some descendant classes that cannot cause condition that will lead to the execution of this particular section of code. Is this the reason I get the incomplete coverage result, and how do I cope with it?
K.v.S. wrote:
Is this the reason I get the incomplete coverage result, and how do I cope with it?
That is plausible. You could add tests for the base class itself. Or you could add another derived class that does need the specific base class code, and test it. :)
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get. Show formatted code inside PRE tags, and give clear symptoms when describing a problem.