S h o r t S t o r i e s

// Tales from software development

NUnit and application configuration files (again)

leave a comment »

I suggested in NUnit and application configuration files that the config file for the application being tested under NUnit could be copied in the test setup method from where it was known to be to the location that the AppDomain that NUnit had created indicated it expected to find it, as specified in the AppDomain.CurrentDomain.SetupInformation.ConfigurationFile property.

This works OK when the application is using the .NET Settings support that was introduced in .NET 2.0. These settings are found under the applicationSettings element in the config file.

However, I’ve now found that if the application uses the System.Configuration.Configuration manager directly then copying the config file doesn’t seem to provide a usable solution because it seems that this gets initialised very early in the process of setting up the execution environment, i.e. before the test setup method copies the config file to the location specified by AppDomain.CurrentDomain.SetupInformation.ConfigurationFile.

In this case the only thing that works is to follow the information regarding config files in the NUnit documentation. If you’re using one AppDomain for all your test assemblies then you need to create a copy of the config file with the same filename as the NUnit project but with a file extension of .config.

Advertisements

Written by Sea Monkey

August 18, 2011 at 8:00 pm

Posted in Development

Tagged with ,

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: