Tuesday, 8 April 2008

Useful tip for testing with NUnit - for when you are testing a class library that (obviously) has no config file ...

When you are testing a class library, that depends on the executable's config file, you can find yourself in bit of a fix. NUnit does allow you to use a config file, but it needs to be in the same directory as the build of the test project (which is also a DLL) and named <test_lib_name>.dll.config.

This is the easy way to get yourself setup to test against a DLL - you go into the project properties, and you put the following command into the "Pre-Build Event Command Line" box:

copy /Y "$(ProjectDir)App.config" "$(TargetDir)$(TargetFileName).config"

You then copy your App.Config file from your EXE project and away you go - the command provided (above) takes care of naming the config file and copying it to the right directory evey time you build the project!

No comments:

Post a Comment

Migrating (and Open-Sourcing) an Historical Codebase: SVN-to-Git

I have a SVN repo on my local machine that I have been shoving stuff into since before I knew how to use revision control systems properly (...