24
votes

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.

11
none of the solutions worked. how did you solve it?Eakan Gopalakrishnan
See my answer below, that's what I did to solve it. Essentially created a new library and copied code over.taylonr
Make sure the classes are public.Rok Povsic

11 Answers

13
votes

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.
10
votes

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

3
votes

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
votes

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
votes

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

1
votes

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>
1
votes

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
0
votes

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

0
votes

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
votes

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
votes

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

Applications folder