As discussed in the FAQ you can use access appSettings values from a .config file.
I discovered a way of making this just a little bit easier to manage:
- Add an App.Config file to your Class Library root folder along with all your tests, and rename it to match the name of the .dll of the unit test class library (e.g. MyProject.Tests.dll.config)
- Add your config settings (i.e. appSettings and so on) in the normal way
To get round this problem without having to move the config file:
- Add a pre-build command to the unit test project:
(i.e. under the Project Properties dialog (Build Events | Pre-Build Command Line)) - enter the following command:
xcopy $(ProjectDir)$(TargetFileName).config /YR
this will copy the [tests.dll].config file to the (Release or Debug) bin folder
Assumptions:
- This advice applies to VS2003, it is probably very similar for VS2005but I've not tried it (in fact, if I remember correctly, VS2005 has amuch more intuitive method for copying files into the bin directory atbuild time which won't need an xcopy command...)
- Your unit tests reside in their own Class Library project
