Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

Code Coverage in Separate Solution
CoolBreeze
#1 Posted : Friday, July 11, 2014 4:10:31 PM(UTC)
Rank: Advanced Member

Groups: Registered
Joined: 7/11/2014(UTC)
Posts: 79
Location: United States of America

Was thanked: 9 time(s) in 9 post(s)
I just downloaded, installed, and enabled NCrunch.

I'm using: VS 2012, Gallio, MbUnit.

I've a main solution with several projects. At this point I want to test code in one key project in the main solution. I'll want to test code in the other projects at some future time.

I've a second separate test solution with the test code. In the test solution I added a reference to the project DLL in the main solution.

I enabled NCrunch and then successfully ran the tests in the test solution. I see the markers on the test code lines.

I want to see code coverage information for the project code in my main solution.

Is there a way to do that?

Ed
CoolBreeze
#2 Posted : Monday, July 14, 2014 9:06:21 PM(UTC)
Rank: Advanced Member

Groups: Registered
Joined: 7/11/2014(UTC)
Posts: 79
Location: United States of America

Was thanked: 9 time(s) in 9 post(s)
Should I move my tests from my test solution to my main solution in order to see the code coverage information for the code files in the main solution?

Thanks, Ed
Remco
#3 Posted : Monday, July 14, 2014 11:07:42 PM(UTC)
Rank: NCrunch Developer

Groups: Administrators
Joined: 4/16/2011(UTC)
Posts: 6,976

Thanks: 931 times
Was thanked: 1257 time(s) in 1170 post(s)
Hi Ed,

Thanks for posting!

Yes - you will need to move your test projects into your main solution in order to see the code coverage information.

NCrunch treats loaded and referenced projects very differently to referenced assemblies. If your code is referencing a DLL outside the solution, NCrunch will consider this to be 3rd party code and it won't instrument it or try to analyse code coverage over it. Projects that are inside your solution and are referenced using the MSBuild ProjectReference tag are considered to be your code, and NCrunch will analyse it and give you data related to it.

It is possible to have a test project that uses ProjectReference tags (rather than DLL Reference tags) to your production code, and have this loaded inside a separate solution without your production code. When the test solution is open, NCrunch will detect the project references and will load the production code as though it were part of the same solution. This means that you could potentially view code coverage information for the production code without needing to have a solution containing both the production projects and the test projects. However, in practice this would be fairly useless, as the VS IDE itself wouldn't load the production projects or have them visible in the solution explorer. This means that even though you may have code coverage information, you'd still have no way to easily edit the projects because VS won't have considered them.

.. So the only practical solution is to have a master solution that contains all relevant test and production projects. If you're concerned about build times, you can also switch off the build of your test projects (inside the VS configuration manager). In this way, NCrunch will still build the projects and run your tests, but Visual Studio will only build your production code when you ask it to perform a build.

I hope this helps.


Cheers,

Remco
CoolBreeze
#4 Posted : Tuesday, July 15, 2014 3:03:40 PM(UTC)
Rank: Advanced Member

Groups: Registered
Joined: 7/11/2014(UTC)
Posts: 79
Location: United States of America

Was thanked: 9 time(s) in 9 post(s)
Hi Remco,

Thank you for your answer. I moved my tests from the test solution to my main solution as you suggested. I can now see the covered or uncovered lines in my main code files.

Thanks!

Ed
1 user thanked CoolBreeze for this useful post.
Remco on 7/15/2014(UTC)
Users browsing this topic
Guest
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

YAF | YAF © 2003-2011, Yet Another Forum.NET
This page was generated in 0.034 seconds.
Trial NCrunch
Take NCrunch for a spin
Do your fingers a favour and supercharge your testing workflow
Free Download