views:

79

answers:

1

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?

A: 

After playing around for a while, it looks like the best way to deal with it is to ensure that for every subdirectory, you add a new DeploymentItem making sure that you specify the "outputDirectory", like so:

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

This allows the tests to run on your machine - hope this helps someone!

Jack