Can’t Reproduce a Bug? It Must Have Been A Cosmic Ray
Dec 14

You can import files for use in your tests using this simple little attribute on your test method:

[DeploymentItem(@"DataAccess\logger.config")]

This ensures that files needed for testing are copied to your test build directory. The path is relative to the solution folder. Simple or what.

Some might say that if you’re relying on external files in your unit tests then you’re not writing clean code. Well if you’re of that opinion and want to come and rewrite a ton of working legacy data access code then be my guest. Otherwise, I’ll have my unit tests passing before you’ve finished typing your argument.

Leave a Reply