Runar Ovesen Hjerpbakk

Science-based software development

Message: The agent process was stopped while the test was running.

In the series of fancy behavior from Visual Studio 2012, we turn today to the MSTest test runner.

While trying to run some tests using Test Explorer, some of them started to fail with the following message:

Message: The agent process was stopped while the test was running.

It turns out that this message appears if the test runner itself has stopped working during the test's execution.

Running the test again in debug mode, revealed the culprit:

StackOverflowException

The code under test had thrown a StackOverflowException, but the error message from the test runner wasn't exactly comprehensive. After fixing the cause of the exception, the tests ran smoothly again.