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

[亡魂溺海] 提交于 2019-12-24 05:52:52

问题


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?


回答1:


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.




回答2:


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.



来源:https://stackoverflow.com/questions/13412733/what-constitutes-full-code-coverage-when-i-invoke-dotcover-from-an-mstest-build

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!