MSTest VS2010 - DeploymentItem copying files to different locations on different machines

Posted by Jack on Stack Overflow See other posts from Stack Overflow or by Jack
Published on 2010-06-16T16:10:21Z Indexed on 2010/06/16 16:12 UTC
Read the original article Hit count: 1782

Filed under:
|
|
|
|

I have found that DeploymentItem

[TestClass(), DeploymentItem(@"TestData\")]

is not copying my test data files to the same location when tests are built and run on different machines.

The test data files are copied to the "bin\debug" directory in the test project on my machine, but on my friend's machine they are copied to "TestResults\*name_machine YY-MM-DD HH_MM_SS*\Out".

The bin\debug directory on my machine can be obtained with the code:

string appDirectory = 
Path.GetDirectoryNameSystem.Reflection.Assembly.GetExecutingAssembly().Location;

and the same code will return "TestResults\*name_machine YY-MM-DD HH_MM_SS*\Out" on my friends PC.

This however isn't really the problem. The problem is that the test data files I have made have a folder structure, and this folder structure is only maintained on my machine when copied to bin\debug, whereas on my friends machine only the files are added to the "TestResults\*name_machine YY-MM-DD HH_MM_SS*\Out" directory. This means that tests will pass on my machine and fail on his!

Is there a way to ensure that DeploymentItem always copys to the bin\debug folder? Or a way to ensure that the folder structure will be retained when DeploymentItem copies the files to the "TestResults\*name_machine YY-MM-DD HH_MM_SS*\Out" folder?

© Stack Overflow or respective owner

Related posts about c#

Related posts about data