How do I make Resharper stop flagging my test function as not used?

481 Views Asked by At

I'm using xUnit for unit testing and in one of my test classes I have 65 tests. Resharper is flagging one of them as not used and is keeping the file flagged yellow/orange until I delete it. I don't want to delete it. I want to keep that test method.

2

There are 2 best solutions below

1
On

I assume that you have xunitcontrib for ReSharper installed, since other test methods are not marked as unused. I also assume that your method is public and has the same test attributes as other test methods (e.g., Fact or Theory). If that is not the case, you might check that you have external annotations for attributes of this method (they are provided with xunitcontrib for ReSharper).

One of possible reasons for incorrect issue reporting by ReSharper is that some of its caches have not been updated. If you can reproduce the problem (given that almost a month passed since you asked your question, it seems to be unlikely), try clearing caches via menu RESHARPER -> Options -> General -> Clear Caches and then restart Visual Studio.

0
On

It could also be that the ReSharper annotations are turned off.

You could verify this via RESHARPER > Options > Code Inspection - Code Annotations.