How can I get "Copy to Output Directory" to work with Unit Tests?


Question

When I build a unit test project before the tests are executed the test output is copied to a TestResults folder and then the tests are executed. The issue I'm having is that not all the files in the Debug/bin directory are copied to the TestResults project.

How can I get a file that is copied to the Debug/bin directory to also be copied to the TestResults folder?

1
123
9/30/2015 8:55:58 AM

Accepted Answer

The standard way to do this is by specifying the deployment items in the .testrunconfig file, which can be accessed via the Edit Test Run Configurations item in the Visual Studio Test menu or in the Solution Items folder.

121
7/13/2011 3:42:11 PM

You can specify deployment attribute like an example shown below; Also you need to set "Content" & "Copy if newer" property ( there is no documentation on the later settings, but you have set those to make it work.

[TestMethod]
[DeploymentItem("mytestdata.xml")]
public void UploadTest()
{



}

Licensed under: CC-BY-SA with attribution
Not affiliated with: Stack Overflow
Icon