How do I get DLL's, from external projects, in my test solution to collect code coverage #'s?
-
25 июня 2012 г. 22:57
I'm writing a C# based test project that references several DLL's that my development team is producing. I need to be able to use the Code Coverage feature of Visual Studio (Using 2012 RC) to see how well my tests are covering the code in these DLL's. But, no matter how I configure my Test Settings, I can't get the DLL's my test code references to appear in the Code Coverage report...It's only reporting on my test project coverage???
I've created a Test Settings file based on this link: http://technet.microsoft.com/en-us/query/ms182480
And, I've configured the Code Coverage section of "Data and Diagnostics" to include the DLL's my code is referencing. But, nothing happens?
I'm really confused as to when the instrumentation is supposed to happen and how to get the DLL's and their methods to appear in my Code Coverage results???
Help!
- Изменено JFamme 25 июня 2012 г. 22:58 added info
Все ответы
-
26 июня 2012 г. 0:33
Hi JFamme
TestSettings are for VS2010 only. They can be used in VS 2012 but are really only there for backwards compatibility. You shouldn't create new ones in 2012. The reason is that they only support MSTest tests and cannot use the new pluggable test runner architecture.
This article explains how code coverage works in 2012.
You will see that CodeCoverage in 2012 " instrument native and managed binaries (DLLs/EXEs) as they are loaded at runtime as long as these binaries are a part of your solution"
Given that your dll's are not part of your solution you need to customize things slightly.
There is a new .runsettings file that you can use. If you go to this blog
it runs you through how to create a runsettings file and add it to your solution. If you make sure that the inclusions section is empty (include all) e.g.
<Include></Include>then it should work fine (I tested your scenario and it worked for me.)
Please mark as answer if this helps.
- Помечено в качестве ответа JFamme 30 июня 2012 г. 0:03
-
27 июня 2012 г. 15:16
I've followed the instructions in the blog...thanks for those. Another question.
In the Code Coverage results, should the hierarchy be showing the development DLL's that my code is testing, with the percentages that they're being covered by the test project methods...because all I'm seeing is my test project DLL's and it's methods with Code Coverage numbers? I think I'm still missing or misunderstanding something???
Thanks!
-
27 июня 2012 г. 22:49
Hi JFamme
The Code Coverage results should show all of the Dll's and their coverage. I have attached a picture of my results.
This shows my unit test project (unittestproject1). This has a project reference to sut.dll, which in turn has a file reference to account.dll
Is this not what you see?
Please mark as answer if this helps.
-
28 июня 2012 г. 3:38
Hi JFamme
I blogged about how to set it up here.
http://scrumdod.blogspot.co.nz/2012/06/visual-studio-2012-code-coverage.html
Please mark as answer if this helps.
- Помечено в качестве ответа JFamme 30 июня 2012 г. 0:03
-
29 июня 2012 г. 20:41
Yeah...What you're seeing, is what I "expected" to see, but I haven't seen that yet. But, I'll checkout your blog and keep trying.
Thanks for your help so far...

