Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Execute only one unit test while debugging in Visual Studio 2008

Is there a way to select which TestMethods you want to execute in Visual Studio 2008 Unit Test project while debugging? I want to debug one particular test without having my other TestMethods execute during each debug session.

like image 597
Michael Kniskern Avatar asked Nov 05 '08 21:11

Michael Kniskern


People also ask

How do I debug a single unit test in Visual Studio?

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.

How do I run a specific unit test in Visual Studio?

Run tests in Test Explorer If Test Explorer is not visible, choose Test on the Visual Studio menu, choose Windows, and then choose Test Explorer (or press Ctrl + E, T). As you run, write, and rerun your tests, the Test Explorer displays the results in a default grouping of Project, Namespace, and Class.


2 Answers

Click on a test method name, then press Ctrl+R, Ctrl+T. (Or go to Test / Debug / Tests in Current Context.)

like image 148
Jon Skeet Avatar answered Sep 29 '22 15:09

Jon Skeet


CTRL-R + T = Run test in context. This can easily be triggered inside a test.
CTRL-R + A = Run all tests
CTRL-R + C = Run all tests in class
CTRL-R + N = Run all tests in namespace
CTRL-R + F = Run all checked tests (good for rerunning al failing tests)

CTRL-R + CTRL-T = Debug test in context, ie. it also attaches debugger
This also works for all other combinations.

like image 23
Dennis van der Stelt Avatar answered Sep 29 '22 17:09

Dennis van der Stelt