Thursday, August 16, 2007

NUnit and App.config files

I was having problems getting NUnit to recognize and use the correct config files for the projects that I was running.
There were several reasons why I was getting runtime errors. Here is a list of them:

1) NUnit is looking for a config file with the same name as the assembly. - renamed the config to {assemblyname}.config
2) VS 2005 is supposed to copy over the App.config to bin/Debug(Release) at compile time and rename it to {assemblyname}.config, mine was failing to do that for some reason. - manual copy worked. Postbuild event should work too.
3) Nunit's project name has to be the same as the assembly name i.e. Project1.nunit won't cut it; it has to be named {assemblyname}.nunit- rename the project name.

After all of the above criteria are met, NUnit should be able to run tests on projects that have config files. I think this problem comes up only with dlls.

No comments: