Build/Test Issues

Code coverage issue

Started by wekempf on 6,636 views

I submitted a bug report for this. However, the submission doesn't provide any feedback. There's no way for you to contact the submitter, and no way for the submitter to get any information about the bug's progress. So, I'm going to provide feedback here as well. :)

I've got a project that's not displaying correct code coverage. I believe this is due to NCrunch not fully considering code run in a [SetUp] (MbUnit) method to be part of a test. The code in the [SetUp] method is marked green, but the code called by this method is displayed with black dots instead of green dots and is not considered to be covered by any tests. When I copy the code from the [SetUp] method to the [Test] method, everything lights up in green. I follow a specific pattern in my unit tests (see http://specificity.codeplex.com) that makes this a pretty serious issue, as NONE of my code is considered covered even though it is quite thoroughly covered.

Edit: I've played around some more, and the issue is a bit different than I suspected. Code I directly put within a [SetUp] method is covered correctly. Specificity, however, uses a base class with EstablishContext and Because virtual methods that are called by a [SetUp] method declared in the base class. My actual unit test derives from this base class and overrides the EstablishContext and Because, and it's this code that doesn't get fully evaluated for test coverage. To reproduce this you can easily use Specificity (it is available in NuGet). If you'd like some example code that demonstrates the issue you can contact me through the CodePlex project (I'm the author of Specificity).

Edited

Thanks for following up with this one - I saw the bug report come through this afternoon and it's good to have the chance to exchange more information about this problem. I think the first thing to try is to see if 1.34b (released this afternoon) gives you the same problem. 1.34b contained a fix that resolved issues around cross-assembly test inheritance ... I think this may make a big difference for the setup you've described. Please let me know how this goes for you.

Post a reply

Log in to reply.