4
votes

I've written a program that tells me whether all the dlls in a code coverage result file are above a specified code coverage percentage.

It works great except when a dll has 0% code coverage, because dlls with 0% code coverage aren't included in the visual studio code coverage result file at all.

I have access to a list of the dlls that were instrumented for this code coverage run, but I'd much rather just look at the code coverage file if I can.

Is there some way to get Visual Studio to add the code coverage results for dlls where the code coverage percentage = 0%?

2

2 Answers

4
votes

Full disclosure: I am on the team that develops this feature.

Unfortunately, this information is not present in the code coverage file. When a binary is instrumented, we insert special probes to tell us that it exists and to detect when each code block is executed.

We do not save the list of DLLs in the target process, so we only know about instrumented DLLs that get executed (just being instrumented is not enough).

The easiest workaround is what you mentioned in your question.

Thanks for your feedback, though, we will take it into consideration. Sorry for the difficulty here.

0
votes

The trick we're using is to add one Test Project with a special Test which calls a special public static method in every assembly that does nothing more than return true. That way the assembly is hit at least once and the one liner doesn't really impact the total coverage data.

I've used Reflection to do this in some projects, and now we're just adding the CodeCoverageTest project to every solution and the CodeCoverage.Ensure() method in every Assembly.