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.
In the new project dialog box, find the unit test project to use. Type test in the search box to find a unit test project template for the test framework you want to use, such as MSTest (C#) or the Native Unit Test project (C++), and select it. Starting in Visual Studio 2017 version 14.8, the .
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.
Resharper and Test Driven .Net both have this feature in their visual studio test-runners. There may well be other VS plugins too.
According to this answer (By Jon Skeet no less) it is possible in Visual studio natively too. To debug a single test:
Click on a test method name, then press Ctrl+R, Ctrl+T. (Or go to Test / Debug / Tests in Current Context.)
EDIT: (based on a comment from Justin R below) to run a test (as opposed to debugging it) the command is simply:
Ctrl+R, T
@Andrew M's answer is awesome, but I wanted to know where the keyboard shotcuts come from. All you have to do is:
First, click somewhere inside the TestMethod
you want to run, or highlight multiple methods. You can also click on the class or namespace if you want to run all TestMethod
s within that class/namespace.
Run: Test → Run → Tests in Current Context
Debug: Test → Debug → Tests in Current Context
Run: Ctrl+R,T
Debug:Ctrl+R,Ctrl+T
Use Test Explorer to run unit tests from Visual Studio or third-party unit test projects. You can also use Test Explorer to group tests into categories, filter the test list, and create, save, and run playlists of tests. You can debug tests and analyze test performance and code coverage. more…
View → Pads → Unit Tests
Test Write high-quality code with testing tools. Visual Studio for Mac’s integrated test runner helps you run and debug unit tests and automated UI tests. more…
Select one or more tests, right-click, Run Test or Debug Test.
Visual Studio → Preferences → Text Editor → Source Analysis
☑ Enable text editor unit test integration
You can directly run a single test from directly from a test source file,
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