What does dotcover actually count? Rows? Statements?
Answered
Hi
Purely out of curiosity and no "bug report", I wonder _what_ dotcover actually measures?
Some examples...
If A's B property is null this will give 100% coverage...
void FullCoverage(){ A.B?.C(); }
...while this won't...
void NotFullCoverage() {if(A.B!=null) A.B.C();}
..even though it's the same logic.
The same (?) thing is that this method will give full coverage when called even though not all conditions are checked (no matter JIT optimzed or not)
void FullCoverage() {if(true||true||true||true||true||true) 3.ToString()}
Can you give me some insight please?
Please sign in to leave a comment.
Hello Roger,
dotCover provides statements coverage. By statements, we mean points in code on which debugger can stop during program execution. These points are generated by the compiler. dotCover reads them from PDB files during the analysis.
In your examples "A.B?.C()" and "if (true||true||true...)" are single statements - you can't set a separate breakpoint for C() call or for separate OR expression parts. That's why dotCover shows these statements as 100% covered.
Support for better coverage metrics which will take into account such cases is still in our plans.