Test Case Executed without Waiting for TestCleanup to Finish RRS feed

  • Question

  • Hello,

    I am facing an issue while executing MSTEST automated test cases via command line utility vstest.exe. Sometime the TestMethod get executed without waiting to finish the TestCleanup. This is becoming issue for me because TestCleanup has some object cleanup used again in another test case.

    Steps -

    1 TestInitialize Started.

    2. TestInitialize Completed.

    3. Execute Testcase.

    4. TestCleanup Started.

    5. TestCleanup Completed.

     Sometime without reaching to step 5, execution is getting started for New Test case from step 1.

    Any suggestions.



    Thursday, April 30, 2015 9:02 PM


All replies

  • Hi Pradip,

    >>I am facing an issue while executing MSTEST automated test cases via command line utility vstest.exe.

    Do you mean that you run the test with vstest.console.exe? If so, how about using the VS IDE or the MStest.exe?

    I doubt that there are different test methods in different test class in your test project. I met an issue before, we couldn't control the running order for all test methods in different test classes. But for every test method in a single class, as far as I know, it would follow this rule, I mean that the new test method will run after the previous test cleanup run.

    If you really want to test it, I suggest you use the VS IDE, add the breakpoints in your test method, and then debug it one step by one step, so you could know the real order of them.

    But if there are test methods in different classes or different projects in the same solution, I suggest you run them singly(the same class or project), check the result.

    If I misunderstood this issue, please feel free to let me know. Maybe you could share us a simple sample with one drive, I will test it in my side.

    Best Regards,


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Monday, May 4, 2015 8:48 AM
  • Thanks Jack.

    I have implemented workaround using Monitor class.



    Tuesday, May 5, 2015 3:36 PM