How can I stop the Visual Studio Test Runner when a test hangs
Asked Answered
S

5

55

When a test hangs in a loop, the small green progress bar in the test runner does not proceed, but there is no way to stop the test run. Or is there?

VS 2013

Edit: This occured when using the XUnit TestRunner. The Cancel button simply did not show up. After testing various test runners in a new solution, it turned out, that it works with all of them. Finally it also worked with my original solution. So there was some anomaly in the state of my VS environment that caused cancel to disapper.

Saccharate answered 22/1, 2014 at 18:35 Comment(2)
You can kill the test runner process :)Ivers
Yepp, I just thought there would be something smoother, because hanging tests are not soooo rare.Saccharate
G
88

You can click "Cancel" in Test Explorer:

enter image description here

Show Test Explorer by going to TEST > Windows > Test Explorer.

This is in Visual Studio 2013.

Instructions for other versions of VS can be found here

Gunlock answered 22/1, 2014 at 18:36 Comment(8)
Very interesting: I do not have this cancel button! I have there: "Run All" | "Run ..." | "Playlist"Saccharate
It's only available while running a test. And like I said, this is VS2013.Gunlock
I added a link to instructions for other versions.Gunlock
Hmm, never shows up on my machine. Strange. Anyway, this is certainly the answer. I will keep an eye on that. ThxSaccharate
Thanks! Please make sure to mark an answer as correct if it answered your question. And check out the link I added!Gunlock
I guess it is related that I use the XUnit Runner. Might be a bug there.Saccharate
Ah, the one I am talking about is MSTest. That might make a difference. Perhaps tag your question differently? I assumed you were using the default unit testing stuff in VS.Gunlock
Just came to my mind now, that I currently use XUnit in F#. Tagged XUnit. Thx for your input.Saccharate
D
4

Sorry for waking up an old thread:) just wanted to share my solution here, I had the same issue on VS 2015. There is some text below the search input just where the cancel should appear (take a look at @Codeman print screen), the text is actually some description on how you can setup a build for your tests, the text is several lines and at the end you have "do not show this any more" just press it and then the cancel button appears:) Very strange bug, sorry I do not have some print screens of this hope it helps someone

Demigod answered 16/3, 2017 at 19:14 Comment(1)
waking up an old thread is totally fine. stackoverflow even has a bagde to honor this ;-)Saccharate
D
4

VS2015. If the hanging tests are executables instead of DLLs you need to kill those tests in the task manager. You need to close the Test Explorer Window to prevent automatic running. While the tests are running/hanging you will not be able to compile the according project.

Dx answered 12/12, 2018 at 14:41 Comment(2)
Tx. Had this in VS2017. Could not cancel and had to kill the testhost.exe processBedmate
Thank you. I had no idea why my VS2017 hangs. Simply close the Test Window solved my issue.Ruppert
O
1

For me the solution was to go to Task Manager, locate chromedriver and end the task. Visual Studio 2022 Professional version 17.2.3.

Ophthalmic answered 13/6, 2022 at 20:6 Comment(0)
C
-2

Terminate process on cancel screenshot

I have found the solution to this issue. To stop the run after cancel is pressed, just set the 'Terminate process on cancel' option to True.

Crater answered 9/8, 2018 at 18:32 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.