Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I get a Unit Test to copy my DLLs and other files when I run a test?

I'm working on an application and I have created a number of unit tests for it. The project with the test class depends upon 3 third party DLLs. When I go to the bin\Debug folder for the test project, the Dlls are there. But when I run the test, the DLLs are not being copied into the TestResult\\Out folder.

There is also a log4net.config file from another project that I would like to have copied. This one is not showing up in the test project's bin\Debug folder, so that's another issue I have to fix.

How do I get these files to copy when I run the unit test?

Tony

like image 657
Tony Vitabile Avatar asked Oct 17 '11 15:10

Tony Vitabile


1 Answers

I have found if your tests are being deployed to the test area (true by default), copy local won't work in some circumstances such as dynamic assembly loading.

You can either turn this deployment off by using a runsettings file (https://msdn.microsoft.com/en-us/library/ms182475.aspx) and

<DeploymentEnabled>False</DeploymentEnabled>

Or, a small hack (slightly ugly as it requires manual/hard coding the assembly), by using a DeploymentItem for the binary (mentioned in other answers, but, not specific to handling dlls as per the OP):

[DeploymentItem("bin\\release\\iRock.dll")]
[DeploymentItem("bin\\debug\\iRock.dll")]

Recommend doing both debug/release, depending on what is used on your CI/Dev.

like image 186
JamesDill Avatar answered Sep 20 '22 18:09

JamesDill