What constitutes full code coverage when I invoke dotCover from an MSTest build step in TeamCity?
Asked Answered
I

2

1

What is considered 100% when I invoke dotCover from an MSTest build step in TeamCity? Is 100% all of the compiled code? Is it all the code for all the assemblies which the tests have touched? Is it all the classes which the tests have touched?

When I invoke dotCover from a TeamCity MSTest build step which runs My.Tests.dll, which lines are code are being tracked?

Improvvisatore answered 16/11, 2012 at 8:14 Comment(0)
F
2

dotCover only provides reporting on statement-level coverage, where as other tools like NCover also include function and branch coverage.

With a TeamCity MSTest build step you get to specify which assemblies you want the coverage reported for in the "Filters" field. This allows you to just specify an exclude for a .Tests pattern or just include one assembly. See the TeamCity documentation for more details: http://confluence.jetbrains.net/display/TCD7/JetBrains+dotCover

I believe that if you don't specify any filters, all code in all assemblies that were loaded into the CLR are included (you have to cause an assembly load from the code you call, so some assemblies might not be included, this is just the lazily loading of the CLR). This is because tools like dotCover use the CLR profiling API and do not instrument your code upfront. Note that dotCover will exclude assemblies from the GAC.

Fantoccini answered 16/11, 2012 at 8:52 Comment(1)
Either use code in that assembly in a unit test (referencing in VS isn't enough) or explicitly do an Assembly.Load("MyAssembly") in a unit test.Fantoccini
D
0

Not sure if I fully understood your question but will take a shot anyways. As I understand 100% coverage means that every line of code in the project is exercised by your test cases. Basically that means that you have ensured that control flows thru every line of code in your project.

In general I have never seen 100% coverage as its very difficult to test every code path. Consider for example different types of exceptions that are handled by your code, how do you exercise the catch block for each exception by some test case? You would need to simulate an exception somehow, which is not always easy.

Delorasdelorenzo answered 16/11, 2012 at 8:25 Comment(5)
I know this, but what is the actual universe of code which constitutes 100%? If I have x% coverage, x% OF WHAT?Improvvisatore
x% of the total number of lines of code. Lets assume that you have 100 lines of code, then 60% means 60 lines of code are covered while 40 lines are not.Delorasdelorenzo
My question is about how it is determined that I have 100 lines of code.Improvvisatore
Before code coverage can run there is an instrumentation phase where in the coverage tool will do its thing of counting all the lines of code and then stubbing your code so that access to each line of code is tracked. Then during the reporting phase the code coverage tool will generate stats on how many lines of code there were in all and how many were covered. If you want to read more about instrumentation here are some good links blogs.msdn.com/b/phuene/archive/2007/05/03/… doc.froglogic.com/squish-coco/2.0/codecoverage.htmlDelorasdelorenzo
I'll try to sharpen my question even more: When I invoke dotCover from a TeamCity MSTest build step which runs My.Tests.dll, which lines are code are being tracked?Improvvisatore

© 2022 - 2024 — McMap. All rights reserved.