NUnit debugs one test

I am using the NUnit plugin from ReSharper. I cannot find a way to debug a single test. The BUG button always launches all tests, even when I run debugging specifically from one test method.

I am trying to reach a breakpoint with one specific test, and I do not want to bring it to other tests.

Do you know how to do this? Google did not help me with this ...

An example of my test code

[Test] public void IsValidDoer_DoerValid() { var mockRepositoryDoer = new Mock<IDoerRepository>(); mockRepositoryDoer.Setup(c => c.ActiveDoers).Returns(activeDoers.AsQueryable); var doerValidation = new DoerValidation(mockRepositoryDoer.Object); Assert.IsTrue(dModel.IncludedDoers.Any()); } [Test] public void IsValidDoer_DoerInvalidNoQuota() { var mockRepositoryDoer = new Mock<IDoerRepository>(); var activeDoers = listDoers.ToList(); activeDoers.First().QuotaActivity.Clear(); mockRepositoryDoer.Setup(c => c.ActiveDoers).Returns(activeDoers.AsQueryable); var doerValidation = new DoerValidation(mockRepositoryDoer.Object); Assert.IsFalse(dModel.IncludedDoers.Any()); } 
+8
debugging c # nunit resharper
source share
4 answers

Yes. Along with the green and yellow sign code, just click this button and click run, it will run this single test. You just click it as soon as you get the parameters, and depending on what you also installed from Jetbrains, you can also start code coverage here.

You can also add it to an existing session of other tests or create it yourself in a session.

Resharper test

Clarification:

Someone refused this, so I went back and looked and tested it for both MSTEST and NUnit. it's true that 15 tests are undesirable if you only want to debug them. The test was conducted in visual studio 2015 with Resharper 10 and visual studio 2013 with Resharper 8. If you click on the label in a separate test file, it will actually run the code once.

If you run several tests and get a test session in the Resharper runner with three tests, it will show “debug tests” by right-clicking, however, if you select only one, it will execute only one test and thus only hit code once.

+4
source share

We also have the same problem when using ReSharper 10 as a test runner. It will run all tests, even if I configured only one test in a session. It will also run all tests when I used the right click on a test ball for this test.

After installing the NUnit3 test adapter in the Tools> Extensions and Updates> Online section, I could debug tests from the usual Visual Studio 2015 test explorer by right-clicking and choosing Debug Selected Tests. This allows you to run only one test :)

+1
source share

I had the same problem. When you try to debug a single test by clicking on the circle and selecting "Debug (error icon)", it will be debugged for all unit tests.

I resolved it by updating Resharper. I upgraded from Resharper Ultimate 10.0.1 to 10.0.2.

+1
source share

Try right-clicking the specific test code. You should see a “Debug Unit Test” or something like this in the context menu.

0
source share

All Articles