locked
Setup and cleanup scripts with .runsettings? RRS feed

  • Question

  • We have a testing environment where we need to run a setup script (.cmd-file) before starting certain tests. Currently we are using .testsettings files for this purpose, which works great.

    However a problem arose now that we started using MS Fakes and shims, because debugging tests using the ShimsContext throw a UnitTestIsolationException with the error message "Failed to resolve profiler path from COR_PROFILER_PATH and COR_PROFILER environment variables."

    The way to resolve this appears to be to change to a .runsettings file instead, to use the Visual Studio testrunner instead of MSTest. But how can we specify a setup script to be run before the entire testrun using this file format?

    Friday, February 7, 2014 8:08 PM

Answers

All replies

  • Hi,

    Whether you got the same issue when you run unit test with fakes on build server like this thread?

    http://social.msdn.microsoft.com/Forums/vstudio/en-US/63c87449-43a7-4af2-83d6-832de79bf874/failed-to-resolve-profiler-path-from-corprofilerpath-and-corprofiler-environment-variables-?forum=tfsgeneral

    If yes, the solution is to specify the Test Runner to be Visual Studio Test Runner. The customer of that thread used .runsettings file instead of .testsettings file just because VS Test Runner won’t collect code coverage with .testsettings file. I doubt that Visual Studio Test Runner and .test settings should also resolve that error. You can try it. If the error disappear, then you can specify a setup script in test settings file. If only Visual Studio Test Runner and .runsettings can resolve that error, we can’t specify a setup script in run settings file, but you can try to write your own code to run the setup script in AssemblyInitialize method, ClassInitialize method or TestInitialize method.

    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.

    Tuesday, February 11, 2014 3:28 AM
  • No, this is not on a build server, this is on the development machine, running the tests from inside Visual Studio. And these problems appear there, but only when running tests in debug.

    Anyway, I take it it is not possible to do the same thing with a .runsettings file as it was with the .testsettings.  The AssemblyInitialize method is not exactly the same since we have multiple test assemblies, but only want to run the setup script once for the entire test run. But if there is no other way, I guess we'll have to figure out something using this methodology in that case.

    Tuesday, February 11, 2014 8:00 AM
  • Hi,

    I did some search, it seems that this is an existing issue from vs2012 Update 2 when we debug unit test with shims.

    Reference:

    http://connect.microsoft.com/VisualStudio/feedback/details/785411/cannot-debug-unit-tests-with-shims-in-vs2012-w-update2

    VSTest does not perform Shims instrumentation in legacy mode (which may be enabled implicitly, by selecting a .TESTSETTINGS file or explicitly, by specifying it in .RUNSETTINGS).

    And the following Microsoft Connect post a similar issue:

    https://connect.microsoft.com/VisualStudio/feedback/details/785030/unittestisolationexception-when-debugging-tests-using-fakes

    You can try to turn off the global profiling environment to check whether it can help.

    Microsoft said that the issue will be fixed in the next version of VS. I suggest using VS2013 to see whether the issue has been resolved. Meanwhile I also will check it.

    If the issue still existed in VS2013, I am afraid that we have to wait.

    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.

    Tuesday, February 11, 2014 9:43 AM
  • Sorry, I forgot to mention it, but I am using VS2013 Update 1. :(
    Tuesday, February 11, 2014 10:46 AM
  • Hi Peter,

    Sorry, I forgot to mention it, but I am using VS2013 Update 1. :(

    Sorry to hear that. I am afraid that the issue is still not fixed in VS2013.

    In order to check the result with the product team, you could submit this feedback to Microsoft Connect feedback portal: http://connect.microsoft.com/VisualStudio/feedback/CreateFeedback.aspx. After you submit the feedback, you can post the link here which will be beneficial for other members with the similar issue. And I will help you to vote it.

    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.

    Wednesday, February 12, 2014 2:23 AM
    • Edited by Peter Palotas Wednesday, February 12, 2014 8:10 AM
    • Marked as answer by Amanda Zhu Wednesday, February 19, 2014 1:28 AM
    Wednesday, February 12, 2014 8:10 AM
  • Hi Peter,

    Voted it.

    Thank you for your undertanding and support.


    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.

    Wednesday, February 12, 2014 8:21 AM