TeamCity with dotCover does not include all my assemblies in coverage report

只谈情不闲聊 提交于 2019-12-07 02:32:07

问题


I want to run NUnit on TeamCity and generate report with dotCover. But for some reasons I cannot get the coverage report for all my project assemblies.

TeamCity config as below

Teamcity: 6.5.3 
NUnit: 2.5.10 
.NET Runtime: Platform: x86
.NET Runtime: Version: v4.0
dotCover: bundled with TC not customized

I have checked that all *.dll *.xml *.pdb files are there in the directory as expected as below (reference DLLs are not listed)

MY.PROJECT.A.dll
MY.PROJECT.A.pdb
MY.PROJECT.A.xml
MY.PROJECT.B.dll
MY.PROJECT.B.pdb
MY.PROJECT.B.xml
MY.PROJECT.C.dll
MY.PROJECT.C.pdb
MY.PROJECT.C.xml
MY.PROJECT.Test.dll
MY.PROJECT.Test.pdb
MY.PROJECT.Test.xml

MY.PROJECT.Test.dll is executed with NUnit and this assembly is excluded in the coverage report by using *Test* filter. But only MY.PROJECT.A is in the dotCover coverage report whereas MY.PROJECT.B and MY.PROJECT.C are not included.

I checked the log but not error is found.

Any thoughts is much appreciated.


回答1:


Finally, I figured out what is going on, and hope this answer is useful for those who are still struggling with this or similar problem.

Basically, dotCover only includes those assemblies are actually used (more precisely, those assemblies loaded by CLR) by the tests in the code coverage report.

In my case, only MY.PROJECT.A is used by tests, MY.PROJECT.B and MY.PROJECT.C are not used by tests due to external dependencies. and even with using MY.PROJECT.B directives in the tests, it does not count as CLR's lazy loading.

One dummy workaround to show 0% coverage report for these two assemblies is that either use anything in the assembly in the tests, or force load these assemblies by calling System.Reflection.Assembly.Load("MY.PROJECT.B")

Related Question:

  • Visual Studio Code Coverage Not Showing All Assemblies
  • What constitutes full code coverage ...


来源:https://stackoverflow.com/questions/26483960/teamcity-with-dotcover-does-not-include-all-my-assemblies-in-coverage-report

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