VS2017 Test Explorer Hangs Workaround OR How to create an External Tool in Visual Studio

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.

image

This has been reported and I believe the team is working on it.

image

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.

image

Then you will have a new “Kill VSTest Console” tool listed in Visual Studio.

image

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.

image

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!

Leave a Reply