locked
Unit Test and Code Coverage Error RRS feed

  • Question

  • Hello,

    I am randomly receiving the error: "The agent process was stopped while the test was running" when running Unit Tests for a C# project.  It is strange because if I select different tests to run, some of the ones that gave the error previously, may pass.

    Also, when I try to check the Code Coverage results, I get the error: "Cannot find any coverage data(.coverage or .coveragexml) files.  Check test run details for possible errors).  I have Code Coverage enabled for both the .exe and .dll I am testing.  The TestResults folder being created when the tests are run only creates an Out folder and no In folder.  I also get this error sometimes when trying to view the Code Coverage results:  "Code Coverage Analysis engine threw exception: The process cannot access the file 'data.coverage' because it is being used by another process.

    Friday, April 30, 2010 3:11 PM

Answers

  • I had the same error. Apparently it's a bug in the test system, but it only appears when your tests do something wrong.

    I had it in 2 situations:

    1) There's a neverending loop or neverending recursion in one of your tests.

    2) The class you test uses background worker threads to do stuff asynchronously and one of these threads throws an exception that is not caught in your code.

    The funny part is, it's not only the test that is wrong that fails, but random tests start to fail (I guess all tests executed after the bad one, and since the order is pretty much random, it randomizes stuff).

    The first step to fix it is to find out which test messes up, which can be quite difficult given this error doesn't give you any tips as to what and where went wrong.


    Agata
    • Marked as answer by Michael_86 Monday, June 28, 2010 12:42 PM
    Sunday, June 20, 2010 4:04 PM

All replies

  • I am getting the following errors when selecting "Test run error" in the Test Results window:

    Warning 4/30/2010 12:23:58 PM Instrumentation error while processing file FileName.exe:
    Error VSP1024: Unable to open file 'C:\Users\mlaterza\Desktop\XXXXXXX\Development\Release 5.0\Bin\FileName.exe' for writing.. LATERZA

     

    Why is it trying to open the .exe file it it testing for writing - it shouldn't be able to write to that file anyway...

     


    Error 4/30/2010 12:24:02 PM One of the background threads threw exception:
    System.InvalidCastException: Specified cast is not valid.
       at FileName.CheckForExistingClients() in C:\Users\mlaterza\Desktop\XXXXXXXX\Development\Release 5.0\Main\FileName.cs:line 403
       at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
       at System.Threading.ExecutionContext.runTryCode(Object userData)
       at System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode code, CleanupCode backoutCode, Object userData)
       at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
       at System.Threading.ThreadHelper.ThreadStart() LATERZA

     

    Error 4/30/2010 12:24:04 PM This adapter will not be used for this test run.  The following error occurred: Code coverage collection engine threw an exception:
    Error VSP1342 : True
    [
    ]
         Code Coverage LATERZA

     

    Friday, April 30, 2010 5:25 PM
  • Anyone?
    Monday, May 3, 2010 2:39 PM
  • I have the same problem here.

    Since 2 days.

    I run my tests and randomly 1 fails with the messaeg: "The agent process was stopped while the test was running."

    When I just run the failing test, it runs fine...

     

    weird!

     

    I will post an update here when I find a solution

     

    .peter.gfader.

    http://blog.gfader.com/ 

    http://twitter.com/peitor  


    Peter Gfader
    Monday, May 24, 2010 5:19 AM
  • When I run the tests with Resharper everything is fine (All green)

    But with VS2010 I get on 1 test a: "The agent process was stopped while the test was running."

    and sometimes on another test: "Test aborted 

     



    Peter Gfader
    Monday, May 24, 2010 5:25 AM
  • I found the solution to my problem.

    I had some unit-tests for a WCF-service. This WCF service was starting up 2 timers. 
    Those timers caused side effects. 
     --> I disable these timers by default and everything is fine!


    BTW: I use WCFMock to fake the WCF service, so I have "real" unit tests around my WCF service

     

    .peter.gfader.

    http://blog.gfader.com/

    http://twitter.com/peitor 

     


    Peter Gfader
    Saturday, May 29, 2010 5:45 AM
  • I had the same error. Apparently it's a bug in the test system, but it only appears when your tests do something wrong.

    I had it in 2 situations:

    1) There's a neverending loop or neverending recursion in one of your tests.

    2) The class you test uses background worker threads to do stuff asynchronously and one of these threads throws an exception that is not caught in your code.

    The funny part is, it's not only the test that is wrong that fails, but random tests start to fail (I guess all tests executed after the bad one, and since the order is pretty much random, it randomizes stuff).

    The first step to fix it is to find out which test messes up, which can be quite difficult given this error doesn't give you any tips as to what and where went wrong.


    Agata
    • Marked as answer by Michael_86 Monday, June 28, 2010 12:42 PM
    Sunday, June 20, 2010 4:04 PM
  • Did you find any solution for this? I am also facing same issue.
    Friday, June 25, 2010 7:50 PM
  • Agaace has the right idea.  It is a bug in the test system.  If one of your tests or the code it runs is in a loop that is taking too long or neverending, then you will receive this error which doesn't give you any information as to the cause.  The hard part is figuring out which test or tests is actually causing the problem and that should eliminate the other random errors as well.

    Monday, June 28, 2010 12:42 PM
  • 2) The class you test uses background worker threads to do stuff asynchronously and one of these threads throws an exception that is not caught in your code.


    Agata

     


    Hi All,

    i have the same problem: Utest without Code Coverage --> Test ok.

    With Code Coverage --> Tesk ok -and- 2 seconds later --> Error VSP1342.

    I using deployment (tesrunconfig --> deployment --> folder with testdata xml), maybe this thread throws an exception?!

     

    Ciao:

    GG ;-)

     

    BTW: After any UTest error i have +1 VSPerfMon.exe and conhost.exe thread in the tasklist.

    Tuesday, August 17, 2010 11:34 AM