I’ve recently noticed the Test Explorer and runner in VS2017 is less stable and ends up stuck in a weird state where its trying to complete or cancel but it never does.
This has been reported and I believe the team is working on it.
It’s great that the Visual Studio team is so responsive and I do expect a fix in the next week or so but for a development team that uses TDD this is huge issue. We are constantly running tests and this significantly hinders our workflow.
The above bug report also lists a workaround which involves killing the underlying test process. This worked but isn’t convenient enough for our team. So I decided to make it much easier by creating a External Tool in Visual Studio.
Create an External Tool
The process was quit easy. Go to Tools | External Tools… from the file menu in Visual Studio. Click the add button and fill in the fields as follows and then click Apply.
Then you will have a new “Kill VSTest Console” tool listed in Visual Studio.
This was nicer but still needs to be more convenient if we are going to run it many times a day.
Keyboard Shortcut
I love all the keyboard shortcuts in VS. They are always adding new/better ways to access features. You can create your own custom shortcuts too.
Go to Tools | Options in the file menu and then Environment | Keyboard in the options panel. Enter “tools.external” in the “Show command containing” search box and choose the command you want to add a shortcut to. The command are simply numbered incrementally. In my case, mine was the third tool.
Finally click in the “Press shorcut keys” field and then enter the keyboard combination you wish to use. I chose Ctrl+K,Ctrl+V which represents “Kill VsTest” for me.
This new tool has been immensely helpful for our daily workflow and expect to use it until the bug is properly fixed in VS.
If this post was helpful or you have a better solution please share your experiences in the comments below.
Happy (faster) Testing!
We have encountered this problem. However I never see vstest.console.exe running when it occurs. a recent VS 2017 update has reduced the frequency of this, but it still happens. Our tests are all in nunit.
Yes, this happens far less frequently for us too after 2017 updates. Thanks for sharing!
Also for me running taskkill /IM vstest.console.exe /F does absolutely nothing. (well it does say it kills a process, but doesn’t stop the hung test discovery).