views:

43

answers:

1

Is there a way to set a constant depending on whether unit tests are run?
The problem with the unit test framework is de way it deals with dependencies; it will copy files but it does not seem to respect the directory structure. As a solution, I'm checking whether the DEBUG constant is set when looking for files to load but this raises problems when the project execution is not part of a testrun but when it's debug session run by the developer. I have tried setting a TESTRUN constant in the unit test project but this approach fails because it's not set for the project being debugged.

+1  A: 

VS doesn't let you set output directories using the IDE but if you edit the .testrunconfig file manually you can add an output directory. MSTest will create the folder for you and it can be any number of levels deep.

<DeploymentItem filename="item" outputDirectory="outputFolder" />

If you specify a directory in the filename attribute it will deploy an entire directory.

Matt Breckon