4

I have a test project and I'm using MSpec for some of the tests (mixed project with both MSpec and VSTest). I have a method that operates on a text file and requires a path to the file. My problem is that the current directory for the file doesn't include the file I need. I have the file included in my project, marked as content & "copy always".

After the test run I can see the file in the TestResults/[timestamped folder]/Out directory. However, if I debug the test and check Path.GetFullPath("resources\\myfile.txt") in the immediate window it returns:

"C:\\Users\\[username]\\AppData\\Local\\Temp\\cb44d906-d20b-4bfb-9569-c661986eb902\\cb44d906-d20b-4bfb-9569-c661986eb902\\assembly\\dl3\\5e87e3e4\\e2bffa3c_7daacf01\\resources\\myfile.txt"

Am I using MSpec wrong? Or am I just missing some configuration?

Visual Studio 2013, runner: ("MSpec Test Adapter" VS extension by Eugene Duvenage)

jessehouwing
  • 106,458
  • 22
  • 256
  • 341
Mark J Miller
  • 4,751
  • 5
  • 44
  • 74
  • So I just modified my api to accept the content of the file (string or stream) instead of the path. Now I can use an embedded resource. However, I'd still like to get a better answer to this if anyone is willing. – Mark J Miller Jul 28 '14 at 19:23
  • 1
    This is very likely due to shadow-copying the spec assembly. Can you turn it off somewhere in the test adapter settings if such settings are provided? – Alexander Groß Jul 29 '14 at 10:38

0 Answers0