xUnit Unit Test project not reading App.config
07:10 03 Jul 2018

I have a .NET Framework 4.5.2 unit test project with xUnit. Inside my unit test project I have an App.config file with the same appSettings as my Web.config.

When I run my test, ConfigurationManager.AppSettings[] always returns null - indicating that it's not reading the App.config file.

Looking in the bin directory I can see that I have a MyProject.Tests.UnitTests.dll.config file that appears to have the same contents as my App.config.

Is this a bug with xUnit? Do I have to do any xUnit configuration to get ConfigurationManager to work?

.net unit-testing xunit