NUnit projects and config files

NUnit project files (*.nunit) are an easy way to specify test assemblies you want tested during the build or continuous integration. Unfortunately, if you use app.configs in your test assemblies, you will quickly realize that NUnit isn’t loading them. For a test project, a single AppDomain is used (by default).

Today, I figured out how to change the default behavior quite by accident.

In NUnit GUI, go to Tools -> Settings then Assembly Isolation. Changing the Default Domain Usage setting to Use a separate AppDomain per Assembly caused NUnit to load an assemblies app.config.

Or, if you are using the NUnit console, simply add the parameter /domain:multiple and it should work. For example:

nunit-console.exe tests.nunit /domain=multiple

Note this option is only available in NUnit 2.5 or later.