Daily Usage Issues

Issue with code coverage markers

Started by liambrown on 9,208 views

There appears to be an intermittent issue with the code coverage markers. Sometimes they show a line as covered (green spot) that cannot possibly be covered, and similarly they sometimes show a line as not covered (white spot) that must be covered based on the lines around it that are shown as covered. It appears fairly random. When this happens it seems to be an issue with one single code file.

I have tried rerunning all tests, clean and rebuild, restarting Visual Studio and also disabling and re-enabling NCrunch - but none of these rectify the problem. The only way I have found to get it to correct itself is to temporarily delete all tests that hit the code file that is being troublesome, then save (so that it reruns coverage and all has white spots) and then replace the tests temporarily deleted. It then shows correct code coverage markers.

I have got some pictures to show this happening. Apologies for the dodgy obfuscation - needed to hide my code a bit.

First, here we have it showing a green spot (on Line 246) when clearly the method isn't covered by any tests yet:
[img=(- BROKEN LINK -)]Broken[/img]

And now, this is it shown as correct, after forcing it to re-evaluate things:
[img=(- BROKEN LINK -)]Fixed[/img]


This keeps cropping up now and again, and is a right pain.

Edited

Hi,

Thanks for sharing this issue.

I've managed to identify a code coverage consistency problem that can be triggered by certain change sequences made to source files. Although the problem has been long standing, it appears much more often under v2.20 after this version introduced some changes to code coverage handling.

A fix has been included in the v2.21, which has just been released. I recommend giving it a try to see if this solves the problem for you - http://www.ncrunch.net/download.
Thank you - I will install v2.21 and let you know if I see the problem again.
I have been using v2.21 all day, but I'm sad to say this has just happened to me again.

It is impossible for line 111 to be covered and 109 and 110 to not be covered:
[img=(- BROKEN LINK -)]Broken[/img]


Once again - after removing tests, saving, put tests back, saving - it now shows the correct coverage:
[img=(- BROKEN LINK -)]Correct[/img]
Thanks for sharing this. It looks like there's still something not right here in the coverage handling.

When this next appears for you, I'm wondering if you can try the following:

1. Submit a bug report, I'll then check the log for any clear issues
2. Close and reopen the source file - does this make the problem go away?
3. Try deliberately re-running the test with the malformed coverage - does this fix the issue?
4. Try commenting out the line of code with the flawed coverage (in a way that doesn't fail the build), then uncomment it - does this solve the issue for the line of code you changed?

Have you noticed any pattern as to when the problem appears? Does it seems to affect some source files more than others? Are there certain changes that seem to cause it?
Ok, I've managed to reproduce this problem.

It's bad.

Basically, the engine is corrupting code coverage over time in response to source files being added/removed from projects, followed by successive restarts of the engine.

The only way to fix the invalid state is to either remove NCrunch's cache file, or rename the tests involved.

I'm very sorry for the trouble caused by this problem, it slipped the net in a nasty way. I'll have a fix available in the v2.22 that will be released shortly.
Many thanks for looking into this and fixing so quickly. I have just installed v2.22 and will let you know how it goes.
I haven't had this happen again since I installed v2.22, so it looks as though this is fixed. Thanks again.

Post a reply

Log in to reply.