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

前端 未结 19 1575
醉话见心
醉话见心 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条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-22 21:24

    I was able to find the source of my problem by looking in the test result file (/TestResults/*.trx) It provided the full details of the exception that occurred in the background thread, and once I resolved that exception the "agent processed stopped..." error went away.

    In my case I was unintentionally launching the GUI in my unit test, which eventually caused a System.ComponentModel.InvalidAsynchronousStateException to be thrown.

    So my .trx file contained:

       
        One of the background threads threw exception: 
    System.ComponentModel.InvalidAsynchronousStateException: An error occurred invoking the method.  The destination thread no longer exists.
    at System.Windows.Forms.Control.WaitForWaitHandle(WaitHandle waitHandle)
    at System.Windows.Forms.Control.MarshaledInvoke(Control caller, Delegate method, Object[] args, Boolean synchronous)
    at System.Windows.Forms.Control.Invoke(Delegate method, Object[] args)
    at System.Windows.Forms.Control.Invoke(Delegate method)
    ...
    
      
    

    This didn't provide any information on what test caused the error, but it did show me where the exception was, which was very useful.

提交回复
热议问题