When you are running an assembly test in NUnit, you may need to access App.Config values. NUnit loads the App.config files by looking for a file with AssemblyName.config.
However, in the default configuration, that .config file has to be in the same directory as the .nunit project file. For example, we had the following setup:
\src\MyProject\MyProject.nunit
\src\MyProject\MyProject\MyProject.sln
\src\MyProject\MyProject\bin\debug
putting the MyProject.config file in either \src\MyProject\MyProject or in \src\MyProject\MyProject\bin\debug doesn’t work – NUnit can’t find it. Putting it in \src\MyProject works like a charm.
Cory is a developer, organizational change agent, speaker and Innovation Games facilitator and trainer with a passion for helping organizations grow rapidly and optimize the use of their technologies and processes. He currently runs the 






Jack April 5, 2006 at 10:35 am
You, sir, are an evil genius! I spent ages trying to fix a problem which was caused by this. Thanks :-)
Praveen Angyan May 28, 2006 at 3:27 am
I had this same problem and this fixed it. I was using NUnit to test the NHibernate section of my app and it couldn’t find the App.config file. But I didn’t know that.
What I did was put my NUnit Project inside the bin folder. I also had to change the Properties for Configuration File NAme.
Anonymous July 7, 2006 at 3:14 pm
Wow, that worked! Thanks a ton — I wasted well over an hour trying to figure out why my App.config file was not being found.
Matt September 8, 2006 at 8:19 pm
This helped me. Thanks.
I found that I had to have my .config file in the same folder as the nunit file. Both had to have the same root name and since I quickly got tired of renaming project.dll.config to project.config, I decided to turn the problem on its head and name the nunit project file project.dll.nunit. It’s been working fine ever since.
I still don’t like that I have to copy my config file up 2 levels just for nunit to work!!!
Anonymous December 12, 2006 at 10:20 am
Thanks !!!!
You saved my life ^^
Rolf Schmidiger May 10, 2007 at 3:27 am
Please note that the file [myDir]\[myApp].config will only be read if i start “nunit.exe [myDir]\[myApp].nunit”
(the assembly-name does NOT MATTER.. worked for me like this with Nunit 2.4.)
Hope this helps somebody…
Anonymous May 15, 2007 at 5:02 am
Thanks for saving hours of work!
Anonymous May 13, 2008 at 5:58 am
You have saved my life! Many thanks.
What a stupid way for Nunit to work!!!
Anonymous June 25, 2008 at 11:20 am
Here’s another way…..
If you have an NUnit-enabled project with a .config file, you could just open the assembly (.dll) in NUnit instead of the project (.vbproj or .csproj) or solution (.sln) file. It will find the .config file.
Urmil Shah July 14, 2008 at 5:13 pm
Try this
copy /Y “$(ProjectDir)App.config” “$(TargetDir)$(TargetFileName).config”
in your Build Events of test project
Spencer August 28, 2008 at 10:35 am
Just another thank you — my neck was getting sore from banging my head against the wall…
Anonymous June 14, 2009 at 10:23 am
Hurray! 1 hours lost of finding out why my configuration is not loaded!
LKlein December 8, 2009 at 7:00 pm
Thanks Rolf Schmidiger et al…
I had named my nunit file differently than my config:
Project: ProjectA.csproj
Test Project: ProjectATester.csproj
Nunit: ProjectATester.nunit
Config: ProjectA.config
Took some time but I finally renamed the nunit file ProjectA.nunit and put the config file in the same directory…
(This was tougher than it should have been, im thinking…)
Charles Middleton December 22, 2009 at 6:39 am
Thanks a bunch! Spent days trying to sort this out!
Markus Gallagher March 4, 2010 at 6:46 am
You can specify the File Name in the NUnit GUI under Project–>Edit Configuration File Name. Unfortunately, adding a relative directory doesn’t seem to work. So you have to still place the config file in the same directory as your .nunit project file.
jeremy simmons April 5, 2011 at 12:37 pm
nunit 2.5.9.10348
application base: bin\Debug
configuration file name: .exe.config
replace with your dll or exe name…
jeremy simmons April 5, 2011 at 12:38 pm
sorry – edited above. lame blog doesn’t escape angle-brackets. shame.
nunit 2.5.9.10348
application base: bin\Debug
configuration file name: <assemblyname>.exe.config
replace <assemblyname>. with your dll or exe nameā¦
Shyam May 3, 2012 at 2:38 pm
Other way ,
1 . click on file->new project
2. Change Save as type to dll .
3. choose nunit test dll as file name .
4. Ignore warning and click OK
5.add app.confi to nunit project.
6. build your project .
7. run nunit , it will take the config file.