I use NUnit plugin from ReSharper. I can't find any way of debugging a single test. The BUG button always launches all the tests, even when I launch the debug specifically from one test method.
I'm trying to reach a breakpoint with one specific test and I don't want to reach it with the other tests.
Do you know any way of doing this? Google didn't help me on this one...
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());
}
To start debugging: In the Visual Studio editor, set a breakpoint in one or more test methods that you want to debug. Because test methods can run in any order, set breakpoints in all the test methods that you want to debug. In Test Explorer, select the test method(s) and then choose Debug on the right-click menu.
Options. If the selection point in the current code window is within a NUnit test, then under the right mouse click context menu, there will be a new option "Jonno - Debug Current test". Set a break point within the text of the test, use the menu option, and you should be able to immediately debug your test.
To debug the Unit test method, right click the method select Debug Tests. The debugging works as it works in the normal C# project. We can use F10, F11 or F5 keys for the same functionality as we do for normal C# project / ASP.NET Project debugging.
To debug a failed test case you should: check that the input data is correct (open the test case to view and/or update the base level attribute values) check that the expected results are correct (in the Test Report, click on the expected result to view and/or update the expected results for that attribute)
Yes Alongside the code is a green and yellow mark just click this and click run it will run that single test. You just left click it once you will get options and depending on what you also have installed from Jetbrains you could launch code coverage from here too.
You can also choose to append it to an already existing session of other tests or create it in a session all on its own.
Clarification:
Someone downvoted this so I went back and took a look and tested it both for MSTEST and NUnit. it is true it is not desirable to execute the 15 tests if you only wish to debug one. The test was conducted in visual studio 2015 with Resharper 10 and visual studio 2013 with Resharper 8. If you click on the mark in the individual test file it will indeed only run the code once.
If you run multiple tests and get a test session in Resharper's runner with three tests it will, on right click, show "debug tests", however if you only select one it only runs one test and so only hitting the code only once.
We also where having the same issue when using ReSharper 10 as the test runner. It would run all the tests, even if I configured only a single test in the session. Also it would run all tests when I used the right click on the test ball for this test.
After installing the NUnit3 Test Adapter under Tools->Extensions and Updates->Online I could debug the tests from the regular Test Explorer of Visual Studio 2015 by right clicking and selecting Debug selected tests. This does only run this one test :)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With