I have a PowerShell script that shells-out to nunit-console-x86.exe
to run tests in assemblies ( DLLs ) that were built earlier in the script by shelling to MSBuild to compile a VS .sln
Exec { invoke-expression "$BUILD_DIR\Tools\NUnit.2.5.10.11092\nunit-console-x86.exe $full_test_assembly_name /xml:test-results/$test_results_file_name" }
Some of these tests utilize System.Configuration.ConfigurationManager
to load config settings. nunit-console-x86.exe
searches for these config-settings in {$full_test_assembly_name}.dll.config
, but this file does not exist as my script does not create it (for reasons explained below).
Each test-project .csproj includes a local App.config file. When a test-project's tests are run in Visual Studio, nUnit searches for config settings in the local App.config. This behavior is as I expected.
I also have an application .sln with a site/service .csproj as its startup project, plus references to various test-projects. When I run the application .sln's entire test-suite from Visual Studio, upon running tests for any test-project nUnit searches for config settings in the test-project's local App.config.
This behavior is not as I expected -- I would have thought that nUnit would search the web.config located in the startup site/service .csproj.
As an experiment, I removed App.config from one of the test-projects. Now when I run its tests in Visual Studio, nUnit throws errors that it can't find {test-project-assembly-name}.dll.config
. So apparently uUnit by default looks for config settings in {test-project-assembly-name}.dll.config
.
I want my test-script to invoke nUnit to run test-assembly tests so that any config settings are loaded from web.config ( which my build script copies into the build target dir ).
How can I accomplish this ? Can I instruct nunit-console-x86.exe
to load config-settings from a config-file-path I supply as a parameter ? Can I structure my .sln and/or .csproj differently so as to cause uUnit to utilize Web.config for config-settings ?