VS 2010 Test Runner error "The agent process was stopped while the test was running."

driis picture driis · May 11, 2010 · Viewed 33.3k times · Source

In Visual Studio 2010, I have a number of unit tests. When I run multiple tests at one time using test lists, I sometimes reveive the following error for one or more of the tests:

The agent process was stopped while the test was running.

It is never the same test failing, and if I try to run the test again, it succeeds.

I found this bug report on Connect, which seems to be the same problem, but it does not offer a solution.

Has anyone else seen this behaviour ? How I can avoid it ?

Edit

I am still experiencing this bug, and so is many of my colleagues on the same software/hardware setup. I have evaluated the answers so far, but they don't resolve the problem. I am starting a bounty for a solution to this problem.

Answer

mafu picture mafu · Sep 9, 2010

This message is caused by an exception on a thread different from the executing test thread. All answers so far boil down to this simple explanation. It is a known bug in Visual Studio not to display any sensible information in that case.

Visual Studio’s test runner totally chokes if a thread other than the executing test thread throws an exception: It gets swallowed and there’s no output, no chance to intercept and debug and no nothing except a burned-down smoldering mess that was supposed to be your unit test.