F5 to run Visual Studio Test in debugger
Asked Answered
S

2

16

I'm using Visual Studio Test for C++, and am debugging a specific test. Microsoft has provided all kinds of ways to run the test in the debugger, but none that I really like. I am getting tired of having to go find the test code and then press Ctrl+R, Ctrl+T (or mousing around which I hate). I want Ctrl+R, Ctrl+T behavior from any source code context.

Is there a way to hook F5 to run the selected test(s) in the debugger?

I've tried setting my test project as startup, but that makes F5 "unable to start" because the test is a DLL.

Sigmatism answered 3/7, 2013 at 13:21 Comment(1)
I would really like this behavior as well.Orvieto
E
7

Locate your vstest.console.exe to run the test DLL via F5.

In my Visual Studio 2017 Community edition that would be putting the following path into Start external program under Debug settings:

 C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\IDE\CommonExtensions\Microsoft\TestWindow\vstest.console.exe

And as Command line arguments just put the DLLs file name. Now you can use F5 to start debugging a test when Set as StartUp Project.

Ezmeralda answered 17/11, 2017 at 21:42 Comment(2)
It works and answers the question, but personally I think it's a better experience to add a different key-binding to the menu "Test>Debug>All Tests".Mamie
To save someone some time to look it up: /Tests:MytestFunc in the command line arguments after the dll-name runs a specific test...Joh
G
0

I found how to set this using resharper: https://superuser.com/questions/724380/repeat-last-test-in-debug-mode-in-visual-studio-2013 BUT now F5 will not perform Continue in Debug. it seems visual studio don't separate Run and Continue commands. (I am using visual studio 2013) so I set Alt+F5 instead.

Grandmamma answered 6/8, 2017 at 9:14 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.