43

On running an individual test in VS2012, a window is shown at the bottom of Test Explorer that includes (assuming failure) a red icon with "Test Failed" next to it. There follows the failure message with "elapsed time" directly beneath.

I would like to know simply whether there is a way to clear this window. For instance if I right-click my test and select "Debug Selected Tests", it is somewhat confusing as I step through the test that this test-results window still shows the failure from a past test-run.

Coder_Dan
  • 1,815
  • 3
  • 23
  • 31
  • I haven't seen anything related to this. I much prefer the Test Results window from previous versions. – bryanbcook Jul 06 '13 at 12:31
  • 10
    I could not agree more - showing the results from past tests, with no ability to clear them, can be very confusing at times. I wish there was a way to clear previous results, but I have not found one. – Dave Marley Jul 18 '13 at 19:41

6 Answers6

52

Actually, there is a way - clean and then rebuild your solution. Previous test run results will clear right up.

Sparkle
  • 681
  • 5
  • 10
  • 2
    Exactly, if you only re-build the test results are there, by choosing "clean" the results are removed. Great, thanks! – Raffaeu Mar 03 '16 at 14:43
  • 3
    You only need to clean the project the tests are in - sometimes the buid time matters – maniek May 16 '16 at 13:43
  • 3
    Using VS 2017 with NUnit 2 Test Adapter extension, and this solution does not seem to work. I see the tests "refresh", but the previous results are still green. I appreciate that the Test Explorer is much faster and less buggy than previously, but I would like a way to clear results. – Johann Nov 08 '18 at 18:55
  • 2
    This solution DOES NOT WORK in Visual Studio 2019. See comminity post here, MSFT has not responded. https://developercommunity.visualstudio.com/content/problem/457817/test-explorer-output-should-clear-previous-results.html – Shiva Jun 15 '20 at 23:07
  • One must first Clean, then Rebuild. – Display name Jan 03 '22 at 17:01
  • Not a great solution for large projects that take a while to build. – Dan Stevens Mar 11 '22 at 14:56
  • This doesn't work for me, either. My `project\.vs\17\project\TestStore` directory has 1400 files in it and 378,000 directories ... no exaggeration! – MikeB Mar 04 '23 at 23:36
5

Switch the build to a different configuration - eg if in debug, switch to release. Then switch back to debug. This should cause it reload the tests. If vs fails to reload the tests on switching back - just do a build (not a rebuild) as this will trigger it to reload the tests

Danaldo
  • 112
  • 4
  • 17
1

You can't do that. Instead, you can filter which tests are shown to you, if that suits your needs. You can find more information about tests here: http://msdn.microsoft.com/en-us/library/hh270865.aspx

Pang
  • 9,564
  • 146
  • 81
  • 122
n32303
  • 831
  • 1
  • 10
  • 25
0

You could make your tests sleep for a second when invoked:

[ClassInitialize()]
public static void Init(TestContext ctx)
{
    System.Threading.Thread.Sleep(1000);
}

This is only a workaround, but it will at least give you the chance to see the Test Explorer progress bar moving, and won't leave you wondering whether anything has actually happened:

Pang
  • 9,564
  • 146
  • 81
  • 122
StuartN
  • 329
  • 1
  • 9
  • If you go along that path, you could also set a break point on the test's first row, debug test and and you'll also have a change to see a "refreshed" in progress icon in the tests results window. – BornToCode Sep 12 '17 at 19:21
0

In VS 2019 you can unload/reload the project with the tests in to clear the results.

greg84
  • 7,541
  • 3
  • 36
  • 45
0

Delete the folder that contains the test results. This will have different names depending on which test suite you use.

The easiest way is to search all of the files under your solution to look for the name(s) of the test(s) that you want to remove. In my case there's a directory called TestStore. I delete that and my test explorer is now empty. Running Clean on your solution will also clear this directory.

There is also a sanctioned method that removes the test runs via the UI but I find it way to cumbersome. But you may like it. How to: Delete Test Results

Display name
  • 1,228
  • 1
  • 18
  • 29