Charu
Charu

Reputation: 2749

File generation path .net application varies while debugging vs running a test

I am generating an excel file in my application. Now i am trying to test if the application is generating the file and saving it at the right place.

From the Testing side, I am setting the ServerRootPath to TestContext. DeploymentDirectory

Now the problem I am seeing is, if I debug my test, the file seems to be generated in TestResults folder and I can see the excel file but if I run the test, I don't see a folder being created for the run and there's no file as well.

Can someone point, what's really happening here and how is the TestContext different if I debug vs run my tests.

Upvotes: 0

Views: 78

Answers (1)

Alex Paven
Alex Paven

Reputation: 5549

Try to log/trace the values of TestRunDirectory (https://msdn.microsoft.com/en-us/library/microsoft.visualstudio.testtools.unittesting.testcontext.testrundirectory.aspx) and/or other properties of the context to see if you can figure it out. This is still on the local machine and not in TFS or other build system, right? Not sure what else to suggest.

Edit: are you using the normal visual studio test runner or do you have Resharper/DevExpress/other test runner? It's unlikely but they might interfere with the directories.

Upvotes: 1

Related Questions