The Artima Developer Community
Sponsored Link

.NET Buzz Forum
Keeping NUnit config files in sync

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Darrell Norton

Posts: 876
Nickname: dnorton
Registered: Mar, 2004

Darrell Norton is a consultant for CapTech Ventures.
Keeping NUnit config files in sync Posted: May 13, 2005 10:30 AM
Reply to this message Reply

This post originated from an RSS feed registered with .NET Buzz by Darrell Norton.
Original Post: Keeping NUnit config files in sync
Feed Title: Darrell Norton's Blog
Feed URL: /error.htm?aspxerrorpath=/blogs/darrell.norton/Rss.aspx
Feed Description: Agile Software Development: Scrum, XP, et al with .NET
Latest .NET Buzz Posts
Latest .NET Buzz Posts by Darrell Norton
Latest Posts From Darrell Norton's Blog

Advertisement

When doing Test-Driven Development with NUnit, you can add an application config file by adding a file called AssemblyName.dll.config to the executing directory. In VB it's not a problem since the bin directory is it (you could just add the config file to the bin directory and "include in project"), but in C# there is a Debug and a Release subdirectory under bin depending on the Visual Studio solution configuration.

The problem is getting your NUnit config file into those directories without having to maintain two copies. The answer is Build Events, specifically post-build events.

First, add an App.config file to your unit test project. Copy everything from your current AssemblyName.dll.config file into the App.config file. The problem is if your project is a class library, Visual Studio won't rename the file and copy it to the output directory like it does with a Windows Forms project.

Now right-click on the unit test project, select Properties, and select Build Events. Click the ellipses (...) next to Post-build Event Command Line. This will open up a batch file editor. Click the Macros >> button to see which macros are available to you. It even shows you the values you can expect given your current project configuration.

That was just handy information for your benefit. Here is the post-build event you would use to copy your App.config to the output directory and rename it to AssemblyName.dll.config (copy and paste):

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

Now when you rebuild your project, the App.config file will be renamed to AssemblyName.dll.config and copied to the output directory so that NUnit can access it for configuration information. Note that this should work for VB too, in case you want to keep source-controlled files out of your bin directory. Simple!

Read: Keeping NUnit config files in sync

Topic: WS-RM and WS-R Previous Topic   Next Topic Topic: Windows Mobile 5.0 launched

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use