locked
Setting PATH for runs of vstest with C++ unit tests RRS feed

  • Question

  • I have support DLLs used by my native C++ unit tests that reside in a separate path from the unit test DLL. I would rather not have to copy all of these DLLs to the unit test folder as a deployment step. Instead, I would like to add the support folder to the PATH environment variable, or otherwise specify this path as "an additional folder to be searched" to vstest.

    There seems to be just such an option in the testsettings file, under Unit Tests > Folders to use when the tests are run, but setting this to include my support DLL path does not seem to do anything. I am still getting a "Message: Failed to set up the execution context to run the test", meaning that the support DLLs weren't loading.

    The documentation mentions "assemblies" when referencing these settings, so does that mean that this option only works for managed code?

    Is there some other way for me to specify additional DLL paths for vstest?

    Wednesday, December 9, 2015 9:57 PM

All replies

  • Hi kenk77,

    >>I would rather not have to copy all of these DLLs to the unit test folder as a deployment step.

    Maybe you could share us the information about how you really call these dll files from your unit test dll.

    Do you mean that you add them as the references of your test project? Or just like the database source file, we could add it as the deployment item in the testsettings file, and then really call this database resource file in our test code.

    [TestMethod]
    
    [DeploymentItem("MyTestProject\\testdatasource.mdb")]
    
    public void TestMethod2()
    
    {
    
     // TODO: Add test logic here
    
    }
    

    If you mean that actually you want to add some dll files as the references for your test project, and then really call the functions in the dll files, as my understanding, it would be related to the VC++ project references, we couldn't use the dependent item property in our testsettings file.

    https://msdn.microsoft.com/en-us/library/ms182475(v=vs.120).aspx

    I think you have seen this document about the VC++ project references:

    http://www.codeproject.com/Articles/85391/Microsoft-Visual-C-Static-and-Dynamic-Libraries

    But if you mean that you want to use the PATH environment variable for assembly references, I doubt that it would have a limitation for it.

    You could submit the suggestions and ideas: http://visualstudio.uservoice.com/forums/121579-visual-studio. The Visual Studio product team is listening to user voice there.

    Best Regards,

    Jack


    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.

    Friday, December 11, 2015 8:30 AM
  • No, my support DLL is not like a database file.

    My application is organized like follows:

        MainApp.exe calls functions in MainApp.dll

        MainApp.dll calls functions in SupportCode.dll

    My unit tests are testing and calling functions in MainApp.dll.

    The VS project builds MainApp.exe and MainApp.dll (and UnitTest.dll) into the same directory. However, the SupportCode.dll is from a 3rd party and are contained in a separate directory.

    There is actually a lot of DLLs from the 3rd party, and I don't want to have to copy all of the SupportCode DLLs into the MainApp build directory on a deployment step. That is why I would like some way to specify the SuportCode DLL path to vstest or somehow pass that information on to the unit test framework.

    All of this code is C++ and is not managed, so I assume they are not considered assemblies.

    Is there any class in the unit test framework that can be subclassed in order to provide this type of runtime environment information to the unit test executor?

    Tuesday, December 15, 2015 9:53 PM
  • Hi kenk77,

    >>Is there any class in the unit test framework that can be subclassed in order to provide this type of runtime environment information to the unit test executor?

    Sorry for that I didn't find this class in unit test framework, I also discuss this issue with VC++ members, it really has no direct way for this issue.

    Like my previous suggestion,  if possible, you could submit the suggestions and ideas: http://visualstudio.uservoice.com/forums/121579-visual-studio. The Visual Studio product team is listening to user voice there. If you submit it, you could share me the link here,  I will help you vote it.

    Best Regards,

    Jack


    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, December 16, 2015 3:44 PM