Unit Tests and Deployment Items
Sometimes one need an external file when running Unit Tests. The purpose can vary according to the situations:
Get information from a configuration file; Use the file as a source of data; …
Here are several possibilities to deploy those files when running Unit Tests :
Use The DeploymentItem Attribute on the TestClass. This is usefull for configuration files.
|
|
Use the DeploymentItem Attribute on TestMethod. This is usefull for data files.
|
|
Set the CopyToOutputDirectory Property to always on the desired file (config or data).
Open the LocalTestRun.testrunconfig file and Add Deployment Items (the Enable deployment check box must be checked ) :
In all cases the build engine will copy the files to the test run directory. For instance, from the Solution directory , TestResults\User_Computer 2009-07-13 16_11_00\Out .
Note: I wrote this using Visual Studio 2008 SP1.