Build/Test Issues

Base class is not showing any code coverage

Started by nCubed on 2,382 views

Win 10 Pro
VS 2022 Enterprise (v17.7.5)
NCrunch 4.18.0.3
.net6.0

I have an abstract base class that is being inherited by two other classes. Everything in the derived classes correctly show the NCrunch code coverage. However, the base class shows zero code coverage.

I've gone through the documentation for missing code coverage. Deleted the NCrunch cache. Rebuilt the project multiple times. Still no go.

Any suggestions?
Hi, thanks for sharing this issue.

Can you confirm whether the black/white markers are showing on the base class with the missing coverage? (relevant as it determines whether the type is instrumented correctly).

If you run the covering tests under NCrunch with a debugger attached, do breakpoints trigger on the code in the base class?
And just like that the code coverage markers are back again; similar to another user's post a bit ago. FWIW: in the time I had posted the original message, I had done a complete system shutdown and reboot.

To answer your question, there were no markers. Just the standard VS gutter. Thanks!
This post has been deleted.
nCubed wrote:And just like that the code coverage markers are back again; similar to another user's post a bit ago. FWIW: in the time I had posted the original message, I had done a complete system shutdown and reboot.

To answer your question, there were no markers. Just the standard VS gutter. Thanks!


I think this is a UI refresh issue.

If you see this again, can you try closing the source file and re-opening it in VS? This will force the gutter to be rebuilt and re-mounted.

I have seen the above issue before but have yet to track it down.
Was thinking about this and thought I could provide some additional information that may help you:

  • Engine Mode: Impacted Tests only, with a filter to exclude some projects not referenced by this project
  • Only consider tests 'Out of date' if they are 'impacted' = true
  • Base class did not initially exist
  • Created a new class and refactored an existing class' methods to be used in the new class and existing class w/ the base class
  • Add the base class to the new class and existing class
  • Continued to extract methods off of existing class
  • It was at this point where I noticed the base class was not getting any code coverage

Hope this helps in some way. Thanks!
Thanks! Can you confirm whether your refactoring was done manually or with a tool? (i.e. VS built-in refactorings or Resharper)
Remco wrote:Thanks! Can you confirm whether your refactoring was done manually or with a tool? (i.e. VS built-in refactorings or Resharper)


As this was simply moving methods from the original class and into the new base class, most everything was manual. There may have been some minor renaming assistance from R#; but I don't really recall.
Just ran into the same issue. But different scenario. About the best I can recall:
* add new base class
* create new derived class in another project
* in derived class, split the window in VS (pull down from the top of the scroll bar to split horizontall)

The bottom window showed code coverage; not sure if the top did. But I collapsed the bottom split and all the code coverage was gone. I'm thinking this same scenario may have occurred when I first reported it, re: splitting the window horizontally using the scroll bar tool. Does that make sense?
nCubed wrote:Just ran into the same issue. But different scenario. About the best I can recall:
* add new base class
* create new derived class in another project
* in derived class, split the window in VS (pull down from the top of the scroll bar to split horizontall)

The bottom window showed code coverage; not sure if the top did. But I collapsed the bottom split and all the code coverage was gone. I'm thinking this same scenario may have occurred when I first reported it, re: splitting the window horizontally using the scroll bar tool. Does that make sense?


This issue is one that I can explain :)

We don't support the split windows in VS. I know it feels cheap and nasty that we don't do this, but after reviewing what we needed to do to get this to work, it didn't seem worth handling it as it would make our VS integration much more brittle. If you split a window vertically or horizontally, you'll only get the NCrunch markers on one side of the split. When the split is removed, you may need to close and reopen the window for the markers to re-appear.

Post a reply

Log in to reply.