I have source code and unit tests in two different solutions. The test project refers to the source code binaries. How can find the code coverage? If I select "Analyze code coverage" Menu under "Test" menu, Visual studio shows the coverage, but it looks like coverage for test code and not for the source code. When I double click on a test from the code coverage window the highlighting happens for Test code. There is no way to see the code highlighting that could show the covered code in the source code(code under test) which is actually in different solution. I'm using Visual studio 2012 and Nunit(through Nunit Visual studio adapter) as my unit testing tool.
2 Answers
Please state more precisely how you're running your tests - NUnit or VS Test Runner?
However, if you are using NUnit to run the tests as it is tagged in this question, then take a look at the "OpenCover" tool (just google it).
OpenCover is able to launch your Testrunner (and every other executable), then doing the instrumentation and producing a coverage result.
It is easy to configure, e.g.:
OpenCover.Console.exe -register:user -target:Target.exe -filter:+[*]* -output:output.xml
The typical use is to run this in a batch and add an ReportGenerator step afterwards.
We're using it this way within our Continuous integration System (Jenkins).
Comments
Try using a tool such as NCover. I had to do that like you for product code and test code which were in different solutions. It worked. However, you have to read documentation and adjust the settings. Sadly, I forgot those details.