Pressing F5 on a test project should run tests in Test Explorer
This has been suggested before, but didn't get enough votes - Let's see if we can ********* the radar this time!!! (https://visualstudio.uservoice.com/forums/121579-visual-studio-ide/suggestions/11317458-pressing-f5-on-a-test-project-should-run-tests-in)
Right now if you Start a unit test project through F5, you get an error dialog stating that "A project with an Output Type of Class Library cannot be started directly."
(Oddly enough, I get caught by this every time - Maybe I'm not writing enough tests!!!)
A nice solution would be to set the Start action on unit test projects to the same action as Debug Selected Tests, and open the Test Explorer if it was closed. In the same way, should one Start Without Debugging (Ctrl-F5), then that should invoke Run Selected Tests.
Having to mentally change shortcuts for unit test projects is impossible when you've been used to press F5 for 30 years. I always press F5 and always get the error popup instead.
Carl Walsh commented
I've been thinking about this more... I've been wondering if there would be a way to hack together a solution if Visual Studio doesn't think it's worth implementing this...
- Maybe make the unit test project a console app, find the TestResults folder to deduce what was run last, and launch vstest.console by either using reflection to call the Main method or launching a new process (under the debugger?)
- Maybe a VS extension could support this?