Using an app.config file with NUnit3 in a .NET Core console app : <p><strong>The Environment:</strong></p>

<p>I've got three projects in my solution currently:</p>

<ul>
<li>A .NET Standard 2.0 library with some code I'd like to test.</li>
<li>A .NET Core 2.2 console app that references the library to make sure it works.</li>
<li>A .NET Core 2.2 console app created by using the "NUnit Test Project" template in VS.</li>
</ul>

<p>The dependencies in my test project all are all from NuGet:</p>

<ul>
<li>Moq Version="4.10.1"</li>
<li>nunit" Version="3.11.0"</li>
<li>NUnit.ConsoleRunner" Version="3.10.0"</li>
<li>NUnit3TestAdapter" Version="3.13.0"</li>
<li>Microsoft.NET.Test.Sdk" Version="16.0.1"</li>
</ul>

<hr>

<p><strong>The Problem:</strong></p>

<p>The .NET standard library relies on an app.config file being present in any application that uses it. It uses <a href="https://docs.microsoft.com/en-us/dotnet/api/system.configuration.configurationsection?view=netframework-4.7.2" rel="noreferrer">ConfigurationSection</a> and <a href="https://docs.microsoft.com/en-us/dotnet/api/system.configuration.configurationelement?view=netframework-4.7.2" rel="noreferrer">ConfigurationElement</a> attributes to map the values to a class, very similar to this answer: <a href="https://stackoverflow.com/a/14782024/301857">A custom config section with nested collections</a></p>

<p>The .NET Core console app has an app.config file in it, and the library is able to parse values out of it just fine and use them. Yay.</p>

<p>The NUnit console app, on the other hand, has the same app.config file in it, but the library can't seem to see it. As soon as it tries to read a value using <code>ConfigurationManager.GetSection("...")</code> it returns <code>null</code>.</p>

<p>Has anyone gotten an app.config file to work with NUnit3 in an environment like this?</p>

<hr>

<p><strong>What I've Tried:</strong></p>

<p>It <em>seems</em> like <a href="https://github.com/nunit/docs/wiki/Configuration-Files" rel="noreferrer">it supports config files</a>, but I'm not sure if the docs are referring to some special NUnit config file or an app.config file.</p>

<ul>
<li>I tried renaming app.config to my_test_project_name.dll.config</li>
<li>I set the config file "Copy to output directory" setting to "Copy always"</li>
<li>I tried every similar name I could think of <em>(app.config, App.config, my_test_project_name.config, my_test_project_name.dll.config, etc)</em></li>
</ul>

<p>I also tried a few things inside the one test I've written so far, to attempt to set the config file somehow, such as a suggestion to use <code>AppDomain.CurrentDomain.SetData()</code> (didn't work, possibly because NUnit3 doesn't support AppDomain):</p>

<pre><code>AppDomain.CurrentDomain.SetData("APP_CONFIG_FILE", @"C:\Path\To\My\Tests\my_test_project_name.dll.config");
</code></pre>

<p>Although there are tests in the NUnit repo that seem to suggest <a href="https://github.com/nunit/nunit3-vs-adapter-demo/blob/master/src/csharp/ConfigFileTests.cs" rel="noreferrer">using a configuration file in NUnit3 is possible</a>, that particular test file is only referenced in the <a href="https://github.com/nunit/nunit3-vs-adapter-demo/blob/master/solutions/vs2017/CSharpTestDemo/CSharpTestDemo.csproj#L49" rel="noreferrer">.NET 4.5 demo project</a>, not the <a href="https://github.com/nunit/nunit3-vs-adapter-demo/blob/master/solutions/vs2017/NUnit3CoreTestDemo/NUnit3CoreTestDemo.csproj#L10" rel="noreferrer">.NET Core demo project</a>.</p>
