vb.netnunit-2.5

NUnit not reading the configuration file


I have written a NUnit tests for a .NET application. When I run the NUnit, it does not read the connection string values from the configuration file. I tried many solutions with out success, like

  1. Adding <assembly name>.dll.config file in the path where NUnit loads the DLL file.
  2. Adding the configuration settings in NUnit.exe.config/NUnit.gui.config

I wasn't able to read the configuration setting even when run in VSNunit. Is there a solution?


Solution

  • I've assumed

    Try this:

    1. Make sure that you have also copied your app.config to your NUnit Test DLL class library (i.e. project SomeNameSpace.MyClassLib.Test) as well.

    2. Build your NUnit Project (e.g. to SomeNameSpace.MyClassLib/bin/debug) and make sure that following are in the bin\debug (or release) directory

      • the assembly to be tested,
      • the NUnit test DLL and
      • the configuration (SomeNameSpace.MyClassLib.Test.config)
      • any other assemblies needed by your DLL file being tested.
    3. Edit your NUnit Project in the XML view of the NUnit GUI Project editor (menu ProjectEdit, or just edit it in Notepad), and make sure that the test assembly (MyClassLib.Test.dll) and the configuration file names are relative to your appbase

      For example,

      <NUnitProject>
        <Settings activeconfig="Debug" processModel="Default"
                  domainUsage="Default"
                  appbase="C:\Temp\MyProject\MyClassLib.Test" />
        <Config name="Debug" binpathtype="Auto"
                configfile="bin\Debug\MyClassLib.Test.dll.config">
          <assembly path="bin\Debug\MyClassLib.Test.dll" />
        </Config>
        <Config name="Release" binpathtype="Auto" />
      </NUnitProject>