27

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.

chiccodoro
  • 14,407
  • 19
  • 87
  • 130
taylonr
  • 10,732
  • 5
  • 37
  • 66

12 Answers12

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.
ANeves
  • 6,219
  • 3
  • 39
  • 63
Oren
  • 147
  • 1
  • 2
12

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

Michiel Overeem
  • 3,894
  • 2
  • 27
  • 39
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.

ANeves
  • 6,219
  • 3
  • 39
  • 63
taylonr
  • 10,732
  • 5
  • 37
  • 66
  • Are test methods was marked by public access modifier and [Test] atribute as well? (sorry for stupid question) – sll Nov 14 '11 at 07: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 Nov 14 '11 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

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

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>
Simon MᶜKenzie
  • 8,344
  • 13
  • 50
  • 77
1

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
srk
  • 1,625
  • 1
  • 10
  • 26
0

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

jchadhowell
  • 1,131
  • 1
  • 14
  • 25
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.

Alistair Green
  • 462
  • 3
  • 10
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.

Tom Bogle
  • 464
  • 4
  • 18
0

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

Applications folder

navarq
  • 1,075
  • 2
  • 15
  • 20
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.

inejwstine
  • 678
  • 1
  • 10
  • 30