views:

67

answers:

1

I have the files checked in to svn. The key is that I don't want to hardcode the paths to the files. How can I use relative paths and be able to find the data files consistantly?

A: 

The best way to do this is as follows:

  1. Add a directory called "Test Data" to your VS2008 or VS2010 Test Project.
  2. Put your data file in that directory.
  3. In the properties for your data file, Set "Copy to Output Directory" to "Copy if Newer"
  4. Add this attribute to your test method: [TestMethod, DeploymentItem(@"Test Data\", @"Test Data\")]
  5. Your test data will be in the same directory as your assembly when you run the unit tests.
Cameron Peters