Background
When using NUnit, I tended to include unit tests in their projects, so they would be built as part of the .dll or .exe depending on the output type (so they were excluded in release builds).
Visual Studio's unit tests are built as separate libraries. This is good in that it further removes dependencies, but removes access to internal methods: unit testing of internal methods was something I'd catered for since using JUnit, although in practice I can't remember many times that I've really needed to call an internal, rather than testing against the public interfaces.
Each project (e.g. libraries) now has a settings file, and VS 2008 takes care of maintaining a skeleton app.config within each project that contains the relevant applicationSettings section. Typically a unit test for a library will depend on a lot of configuration for other libraries, e.g. application settings, WCF, etc. Having a separate App.config under each unit test project with all this information means duplicating a lot of information that may change (e.g. locations of web services or databases required for tests).
Solution
Under 'Solution Items', add a new App.config that will be the master configuration for development and unit testing. Then configure each unit test project with a post-build step to copy this configuration into the output directory using the 'Build Events' tab in the project settings.
1 comments:
Thanks for the tip, that was a big help. Looks like you're missing a double quote at the end, though.
Post a Comment