Reputation: 106530
I have a set of unit tests which I would like to run in Team Foundation Build. These tests read a set of files from the file system, and check for errors. I can't move the test file data into my test DLL, because the whole point is to check that these files, which are shipped/bundled in the installer, are valid.
When I run tests locally this works fine, because the tested DLL has a dependency on these files, and as such, Visual Studio copies them over when building the test DLL. But when run on the build server, the build server copies the test DLL into a different directory, along with the assemblies that it references directly or indirectly as declared in its metadata. As a result, the tests can't find the files under test, because they aren't declared as "dependent assemblies" (and can't be).
How can I fix this?
Upvotes: 1
Views: 91
Reputation: 2335
Within the .testsettings
dialog there is a category called Deployment. If you enable this you can add files and or directories which you want to deploy with the build.
Assuming you're using MSTest, in addition you put a [Microsoft.VisualStudio.TestTools.UnitTesting.DeploymentItem(path)]
attribute, one per file, on the test method that will use the dependencies.
E.g:
[TestMethod]
[DeploymentItem("TestData/file1.xml")]
[DeploymentItem("TestData/file2.xml")]
public void IntegrationTestMethod()
{
//...
}
Upvotes: 3