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

Notification

Icon
Error

Code coverage not appearing (newbie question)
Grendil
#1 Posted : Monday, April 17, 2017 2:58:59 AM(UTC)
Rank: Advanced Member

Groups: Registered
Joined: 3/18/2017(UTC)
Posts: 54
Location: United States of America

Thanks: 22 times
Was thanked: 11 time(s) in 10 post(s)
I'm fairly new to NCrunch and I'm currently seeing a behavior I don't understand. I'm guessing it's probably easily explained by someone with more experience. My tests are running green, and show as such with the code coverage markers. However some of the classes they are testing are marked as almost entirely uncovered, and I'm not sure why. The very first line in these subject classes are marked as covered, and occasionally a few other lines, but all the rest are marked as uncovered. Yet I can step through a test run and see the subject's code getting hit, even while those very lines are showing uncovered. I believe they used to show as covered, and that I've probably done something to "uncover" them, but I haven't yet figured out what.

A few possibly relevant things:
I've reset NCrunch and rebuilt my solution numerous times to try to rectify this.
The Instrument Output Assembly setting is enabled (IOW I've verified the default setting is in effect.)
I had been using ncrunch comment syntax to disable ncrunch handling for certain classes, and in those cases I just put the start comment on the first line and not put an end comment at all. But I've since turned that back off.

Thanks in advance for any illumination.
Remco
#2 Posted : Monday, April 17, 2017 11:12:28 AM(UTC)
Rank: NCrunch Developer

Groups: Administrators
Joined: 4/16/2011(UTC)
Posts: 7,161

Thanks: 964 times
Was thanked: 1296 time(s) in 1202 post(s)
Hi, thanks for posting.

Which engine mode do you usually work in? If you're using 'Run impacted tests automatically, others manually', and you haven't changed your physical code since you used the coverage suppression markers, it's quite possible your coverage data is out of date and you just need to run all your tests again using the 'Run all tests' button on the Tests Window.

This documentation page is also worth a read: Missing Code Coverage.

If the NCrunch coverage database has somehow fallen out of sync and is corrupted, deleting the _NCrunch_SOLUTION directory adjacent to your solution file with the engine disabled should resolve the problem.
2 users thanked Remco for this useful post.
Grendil on 4/18/2017(UTC), martinklinkexavo on 4/26/2017(UTC)
Grendil
#3 Posted : Monday, April 17, 2017 11:34:40 PM(UTC)
Rank: Advanced Member

Groups: Registered
Joined: 3/18/2017(UTC)
Posts: 54
Location: United States of America

Thanks: 22 times
Was thanked: 11 time(s) in 10 post(s)
Remco;10278 wrote:
Which engine mode do you usually work in? If you're using 'Run impacted tests automatically, others manually', and you haven't changed your physical code since you used the coverage suppression markers, it's quite possible your coverage data is out of date and you just need to run all your tests again using the 'Run all tests' button on the Tests Window.
I'm using "Run All Test Automatically". I've also hit "Run all tests" now just to be sure.
Remco;10278 wrote:
This documentation page is also worth a read: Missing Code Coverage.
I read through that. It was interesting reading, but unfortunately it didn't clear me up. It seems like if I step though a test and it calls a instance method in the subject code it calls, those lines should appear as covered by that test. Is it more complicated than that?
Remco;10278 wrote:
If the NCrunch coverage database has somehow fallen out of sync and is corrupted, deleting the _NCrunch_SOLUTION directory adjacent to your solution file with the engine disabled should resolve the problem.
I tried this, but it did not seem to help.

I've noticed that the code coverage for one test from a test class is displayed, but I haven't yet determined what if anything is different about that test as opposed to its neighbors that aren't being considered for code coverage. All the tests in that class have code coverage indicated for the test code itself.
Remco
#4 Posted : Monday, April 17, 2017 11:41:42 PM(UTC)
Rank: NCrunch Developer

Groups: Administrators
Joined: 4/16/2011(UTC)
Posts: 7,161

Thanks: 964 times
Was thanked: 1296 time(s) in 1202 post(s)
Grendil;10279 wrote:

Remco;10278 wrote:
This documentation page is also worth a read: Missing Code Coverage.
I read through that. It was interesting reading, but unfortunately it didn't clear me up. It seems like if I step though a test and it calls a instance method in the subject code it calls, those lines should appear as covered by that test. Is it more complicated than that?


In most cases, yes. It looks to me like something may be misbehaving, or you've managed to set a configuration option that is giving unexpected behaviour.

I think we should reset your configuration entirely. Close down your IDE, remove the _NCrunch_SOLUTION directory, delete all the ncrunch derived files (ncrunchproject, ncrunchsolution), delete the global config file(s) at C:\Users\USER\AppData\Roaming\NCrunch, then reopen your solution to see if this solves the problem.

If not, it's probably a problem with the engine that's being somehow triggered by the structure of your code. Unfortunately to troubleshoot it further, I'll need a code sample that can compile and reproduce the issue.
1 user thanked Remco for this useful post.
Grendil on 4/18/2017(UTC)
Grendil
#5 Posted : Tuesday, April 18, 2017 12:14:03 AM(UTC)
Rank: Advanced Member

Groups: Registered
Joined: 3/18/2017(UTC)
Posts: 54
Location: United States of America

Thanks: 22 times
Was thanked: 11 time(s) in 10 post(s)
Remco;10280 wrote:

In most cases, yes. It looks to me like something may be misbehaving, or you've managed to set a configuration option that is giving unexpected behaviour.

I think we should reset your configuration entirely. Close down your IDE, remove the _NCrunch_SOLUTION directory, delete all the ncrunch derived files (ncrunchproject, ncrunchsolution), delete the global config file(s) at C:\Users\USER\AppData\Roaming\NCrunch, then reopen your solution to see if this solves the problem.

If not, it's probably a problem with the engine that's being somehow triggered by the structure of your code. Unfortunately to troubleshoot it further, I'll need a code sample that can compile and reproduce the issue.


OK, I'll try it and report back. Thanks for all your help.
Grendil
#6 Posted : Tuesday, April 18, 2017 7:30:27 AM(UTC)
Rank: Advanced Member

Groups: Registered
Joined: 3/18/2017(UTC)
Posts: 54
Location: United States of America

Thanks: 22 times
Was thanked: 11 time(s) in 10 post(s)
So after a full NCrunch lobotomy I believe everything is back to normal! Comparing the old and new config files didn't really reveal a mistake the way I was hoping it would, and in fact dropping my personal configs back in didn't break anything again. So my novice guess is that when I added ncrunch no coverage start comments at the top of some of my helper classes, I somehow corrupted the NCrunch cache directory, such that even after I removed them I didn't get full coverage back. Deleting and recreating it may have been the key to recovery.

Some of that ncrunch-commented helper code was invoked in test-decorating attribute constructor code, so this may have forged an unexpected code path in NCrunch. Also I never provided closing comments, as my intention was to exclude the whole file from test coverage, and perhaps that was bad form. I'm short on time at the moment, but if I get some spare time I'll try to recreate the problem.
Remco
#7 Posted : Tuesday, April 18, 2017 7:54:19 AM(UTC)
Rank: NCrunch Developer

Groups: Administrators
Joined: 4/16/2011(UTC)
Posts: 7,161

Thanks: 964 times
Was thanked: 1296 time(s) in 1202 post(s)
I'm glad you managed to resolve this problem, but I'm concerned about the fact that it exists.

If the engine is behaving normally, the ncrunch comments shouldn't create this kind of behaviour. Please do let me know if you find a way to reproduce this.
Grendil
#8 Posted : Tuesday, April 18, 2017 7:18:30 PM(UTC)
Rank: Advanced Member

Groups: Registered
Joined: 3/18/2017(UTC)
Posts: 54
Location: United States of America

Thanks: 22 times
Was thanked: 11 time(s) in 10 post(s)
Remco;10287 wrote:
I'm glad you managed to resolve this problem, but I'm concerned about the fact that it exists.

If the engine is behaving normally, the ncrunch comments shouldn't create this kind of behaviour. Please do let me know if you find a way to reproduce this.


Will do.
CoolBreeze
#9 Posted : Friday, April 15, 2022 4:53:49 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,

I ran into a similar problem.

I was seeing code coverage markers in one of my VB code files.
Then I added ncrunch: no coverage start, no coverage end to some but not all methods.
Then NCrunch didn't show any markers for the entire file.
I closed and reopened the solution.
The markers reappeared.

Remco
#10 Posted : Saturday, April 16, 2022 12:00:28 AM(UTC)
Rank: NCrunch Developer

Groups: Administrators
Joined: 4/16/2011(UTC)
Posts: 7,161

Thanks: 964 times
Was thanked: 1296 time(s) in 1202 post(s)
CoolBreeze;16079 wrote:

I was seeing code coverage markers in one of my VB code files.
Then I added ncrunch: no coverage start, no coverage end to some but not all methods.
Then NCrunch didn't show any markers for the entire file.
I closed and reopened the solution.
The markers reappeared.


Thanks for sharing this. Is this something that you have been able to reproduce with any consistency?
CoolBreeze
#11 Posted : Saturday, April 16, 2022 2:54: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)
For the moment, I only saw this on one file. If I see it again I'll post a reply. Ed
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.064 seconds.
Trial NCrunch
Take NCrunch for a spin
Do your fingers a favour and supercharge your testing workflow
Free Download