locked
Visual Studio 11 Beta Native C++ Unit Test Working Directory RRS feed

  • Question

  • Is it possible to change working directory for unit tests in VS11 beta? Now when I run any test the working directory is C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE
    Saturday, March 10, 2012 3:35 PM

Answers

  • Nikita,

    Thanks for your feedback.

    We have fixed this issue in our latest code and have started setting the working directory to the directory where test binary is present. The fix should be available in the next release of VS 11.

    Regards

    Aseem Bansal 

    Saturday, March 10, 2012 6:58 PM

All replies

  • I had to get working dir in DllMain and write such code in every test class:

      TEST_METHOD_INITIALIZE(Open_file_by_nameInitialize)
      {
        SetCurrentDirectory(modulePath.c_str());
      }

      TEST_METHOD_CLEANUP(Open_file_by_nameCleanup)
      {
        SetCurrentDirectory(previousWorkingDir.c_str());
      }

    I belive this is ugliest solution and there should be a better one

    Saturday, March 10, 2012 5:21 PM
  • Nikita,

    Thanks for your feedback.

    We have fixed this issue in our latest code and have started setting the working directory to the directory where test binary is present. The fix should be available in the next release of VS 11.

    Regards

    Aseem Bansal 

    Saturday, March 10, 2012 6:58 PM
  • This seems counter intuitive - why not set the current directory to the value specified in Project Properties -> Debugging -> Working Directory ?
    Sunday, February 2, 2014 3:13 PM
  • This is apparently the behavior as of VS 2013. As far as I can tell, it sets this directory prior to every test class. So, you can't set a directory for test data in TEST_MODULE_INITIALIZE. It will get set once before the first test, but then reset back to that binary directory for every other test. So, you can't specify a working directory for data that will apply to all tests. You have to add that to every test. What a horrid idea...


    Sunday, July 13, 2014 2:42 PM