First, the problem: Unit testing code that relies on values from configuration files is problematic, since NUnit operates outside the context of those config files.
The solution: NUnit has the facility to read its own config file in its own context (i.e. when the tests are running), therefore we should copy our config to that file.
The strategy:
- Copying files should not be done manually as this is almost guaranteed to screw up - it's also not logically possible for an automated build.
- The automatic process will have to rename the config file to match the NUnit project dll name.
- Any configuration sections that have been split out into separate files will have to be copied across as well and the relative paths to them maintained.
- Each project to be tested must have its own test project. For instance if you have a 'web' project, you should have a 'web.tests' project. Likewise if you have 'DataLayer' project you should have a 'DataLayer.tests' project. This means that you will not have to try to merge configuration from different projects into a single test project configuration.
0 comments:
Post a Comment