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

前端 未结 19 1339
醉话见心
醉话见心 2020-12-22 21:13

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

相关标签:
19条回答
  • 2020-12-22 21:32

    I encountered the same Problem and solved it while Removing

    Environment.Exit(0);
    

    So i am pretty sure, that this error occurs while your test or method under test, is causing the executing process to terminate.

    0 讨论(0)
  • 2020-12-22 21:34

    I had the same problem and it was caused by a finalizer for an unmanaged resource (a file writer that was not getting disposed properly for some reason).

    After wrapping the finalizer code in a try-catch that swallows the exception, the problem disappeared. I don't recommend swallowing exceptions like that, so it would obviously be wise to find out why the exception is occurring in the first place.

    0 讨论(0)
  • 2020-12-22 21:35

    I was able to determine what was causing my issue by looking in the Windows Logs > Application log entries within the Windows Event Viewer. Look for entries at the time the test bombed-out. I had an Error entry similar to below:

    QTAgent32_40.exe, PID 10432, Thread 2) AgentProcess:CurrentDomain_UnhandledException: IsTerminating : System.NullReferenceException: Object reference not set to an instance of an object.
       at XXX.YYY.ZZZ.cs:line 660
       at XXX.YYY.AAA.Finalize() in C:\JenkinsSlave\workspace\XXX.YYY.AAA.cs:line 180
    

    It was indeed a null reference exception within a method called from a class finalizer.

    0 讨论(0)
  • 2020-12-22 21:36

    I have had this happening on the odd occasion, and the culprit almost always turns out to be threading.

    Strangely enough all the tests would work fine on the development machines, then randomly fail on the build servers.

    On closer inspection it turned out that although the tests were being listed as passed on the dev boxes, there were exceptions being thrown. The exceptions were being thrown on a seperate thread which didn't get picked up as an error.

    The exception details were being logged against the test trace, so we were able to identify which code/tests needed to be modified.

    Hope this helps someone.

    0 讨论(0)
  • 2020-12-22 21:37

    I have run into a similar problem where a test is failing in TestInitialize and is also running code from a ddl from another of my projects. I get the error message as described above and if I try to debug the test, the test is just aborted without any exception details.

    I suspect that the problem may be that the dlls from my other project are from a Visual Studio 2012 project and I am running my tests in a VS2010 project, and/or possibly that the UnitTestFramwork dll versions from the 2 projects are mismatched.

    0 讨论(0)
  • 2020-12-22 21:39

    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.

    0 讨论(0)
提交回复
热议问题