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.

2
  • 2
    You can kill the test runner process :) Commented Jan 22, 2014 at 18:36
  • 2
    Yepp, I just thought there would be something smoother, because hanging tests are not soooo rare.
    – citykid
    Commented Jan 22, 2014 at 18:39

5 Answers 5

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

8
  • 20
    Very interesting: I do not have this cancel button! I have there: "Run All" | "Run ..." | "Playlist"
    – citykid
    Commented Jan 22, 2014 at 18:43
  • 5
    It's only available while running a test. And like I said, this is VS2013.
    – Codeman
    Commented Jan 22, 2014 at 18:44
  • I added a link to instructions for other versions.
    – Codeman
    Commented Jan 22, 2014 at 18:45
  • Hmm, never shows up on my machine. Strange. Anyway, this is certainly the answer. I will keep an eye on that. Thx
    – citykid
    Commented Jan 22, 2014 at 18:46
  • Thanks! Please make sure to mark an answer as correct if it answered your question. And check out the link I added!
    – Codeman
    Commented Jan 22, 2014 at 18:47
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

1
  • 6
    waking up an old thread is totally fine. stackoverflow even has a bagde to honor this ;-)
    – citykid
    Commented Mar 16, 2017 at 20:09
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.

2
  • 1
    Tx. Had this in VS2017. Could not cancel and had to kill the testhost.exe process
    – AardVark71
    Commented Sep 27, 2019 at 14:35
  • Thank you. I had no idea why my VS2017 hangs. Simply close the Test Window solved my issue. Commented May 16, 2020 at 22:11
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.

-3

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.