30

I recently converted from MSTest to NUnit. I did this by

  • replacing all occurrences of [TestMethod] by [Test], [TestClass] by [Test], etc.
  • I also deleted the Microsoft.VisualStudio... reference and added the NUnit.framework nuget package.

Since I've done that, Resharper isn't showing the little testing icon next to the methods. And if I run the tests using Ctrl + U, R it shows the right count but doesn't actually run any of them.

Does anyone have any idea?

Edit: There must be something screwed up with my assembly because I created a new one just called Test.Web and created a simple class with just the [TestFixture] and Resharper recognized it instantly.

3
  • 2
    none of the solutions worked. how did you solve it? Commented Aug 12, 2015 at 17:27
  • See my answer below, that's what I did to solve it. Essentially created a new library and copied code over.
    – taylonr
    Commented Aug 12, 2015 at 21:29
  • Make sure the classes are public.
    – Rok Povsic
    Commented Aug 3, 2017 at 4:18

14 Answers 14

14

Removing the .ReSharper.user file from the source directory (in the same directory as the solution file) solved the same problem for me.

3
  • 6
    It's called .DotSettings.User in ReSharper 8.2.3 Commented Aug 26, 2015 at 20:52
  • 2
    10 years later and this solved the problem for me too! Commented Mar 18, 2023 at 19:36
  • 13 years now, fixed it for me! Commented Oct 22 at 8:57
13

I had the same problem and i solved it like this:

  1. Go to Resharper Options -> Tools -> Unit Testing -> Unit testing providers
  2. Unselect anything but Nunit and press OK.
  3. It should work now and you can even reselect the providers that you disabled and it should still work.
3
  • +1 I don't know why but just after installing dotCover, the checkbox that indicate NUnit is activated was unchecked.
    – Samuel
    Commented Mar 26, 2014 at 19:53
  • In my case xUnit detection was the one getting in the way.
    – eglasius
    Commented Jun 27, 2018 at 7:59
  • 1
    Must be relevant to an older version of Resharper. There are no checkboxes to unselect now.
    – Tom Bogle
    Commented Oct 2, 2020 at 11:32
5

For me, right-clicking on the test fixture class name and clicking the Visual Studio's (not Resharper's) "Run Tests" menu item made the R# icons show up again.


enter image description here


P.S. This was in Visual Studio 2017

0
3

There was a problem with the assembly. I'm not sure what. But I created a new blank class library, installed NUnit, Should and Moq. Then copied my classes from the previous assembly into the new one and voilá, everything worked.

2
  • Are test methods was marked by public access modifier and [Test] atribute as well? (sorry for stupid question)
    – sll
    Commented Nov 14, 2011 at 7:58
  • Yes. As I said, it worked in NUnit standalone. Also worked when I copied the files out to another repository. It was not an NUnit problem.
    – taylonr
    Commented Nov 14, 2011 at 20:23
2

I had a problem when it just stopped working for some reason.

The solution was to go Resharper->Options->Tools->"Unit Testing" in each sub item like NUnit, you will go and set checkbox for the tests you want to support. There will be something like "Enable NUnit 3x support".

Like this:

enter image description here

2

I got this working by following the suggestions on this StackOverflow question. Specifically:

  • Add a NuGet reference to Microsoft.NET.Test.Sdk
  • Update ReSharper
  • Restart Visual Studio
1
  • 1
    Adding Microsoft.Net.Test.Sdk was enough for me here in 2023 :)
    – iakob
    Commented Aug 1, 2023 at 10:55
2

This can also happen when NUnit upgrades to a new version (like with 4.0 released on 11/26/23) and R# hasn't caught up. I'm probably the only one dumb enough to upgrade NUnit then wonder why it's not working, but maybe this helps someone else.

1
  • 1
    For anyone else who hasn't updated R# in a while, NUnit 4 support is available in ReSharper 2023.3. Commented Mar 27 at 19:40
1

This can happen when the test class is so large that ReSharper pauses code analysis. For these files, you can right-click on the "pause" icon above the code editor's vertical scrollbar and select "Resume Analysis".

Code Analysis has been paused because document size has exceeded the threshold

This will add a ForceIncluded entry to the solution's .DotSettings.user file, so you won't need to do it again:

<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=.../@EntryIndexedValue">ForceIncluded</s:String>
0

I experienced a similar issue and determined that the MSpec plug-in was interfering. Resolved by disabling MSpec test runner: Resharper->Options->Plugins.

0

This problem can occur if you have multiple test projects with mismatched versions of nunit, NUnit3TestAdapter and Microsoft.NET.Test.Sdk.

When I added a new test project to an existing solution, Visual Studio installed the very latest versions of these libraries by default. All tests worked in the built in Test Explorer, but ReSharper could not see the new test project.

To fix: Right click on the solution in Solution Explorer, choose "Manage NuGet Packages for Solution", then go to the Consolidate tab. Pick the version that you want to use for each of these libraries and install it in all test projects.

0

This was happening in one solution with a large number of projects. (I checked, and it had not paused analysis.) Running tests in all my other solutions worked fine. I tried adding the NUnit 3 Test Adapter package to all my projects, but since I am using Resharper, I was pretty sure that wouldn't fix anything - it didn't. Finally I updated to the latest version of Resharper. The installer said it failed, but after that, Resharper could once again see my unit tests. Hard to say whether this could qualify as an "Answer" but it seems to be what got me back up and running.

0

Update to latest version of resharper and add the location of the applications root directory in you ".testsettings" file

Applications folder

0

Another thing to try is to open the Unit Test Explorer (Resharper > Unit Tests > Unit Tests) and click the Refresh button in the upper left corner. This caused missing unit tests to reappear for me in both the Unit Test Explorer and the All tests from Solution session.

0

I had just a handful of tests showing (XUnit in this example but not sure if that makes a difference).

I went to the root level in the Unit Test Sessions folder hierarchy → right-click → Append All Tests from MySolution and voilà! they all finally appeared. :-)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.