my blog RSS 2.0
 Friday, February 17, 2006

I just emailed Jamie Cansdale at TestDriven.NET but in the meantime, this might come in useful to someone out there using TestDriven.NET...

As discussed in the FAQ you can use access appSettings values from a .config file.

I discovered a way of making this just a little bit easier to manage:
  • Add an App.Config file to your Class Library root folder along with all your tests, and rename it to match the name of the .dll of the unit test class library (e.g. MyProject.Tests.dll.config)
  • Add your config settings (i.e. appSettings and so on) in the normal way
It this point, when trying to run a test, TestDriven (or possibly NUnit itself?) will not be able to find your config settings because the config file should really have been placed in the bin folder but we'd then need to manage 2 copies (one for each of the Release and Debug folders), and anyway, it's easier for you to see and manage the config file if it's in the project root folder along with all your other classes rather than having to move it to the bin folder (because we'd then have to mess about doing 'show all files' and 'include in project')

To get round this problem without having to move the config file:
  • Add a pre-build command to the unit test project:
    (i.e. under the Project Properties dialog (Build Events | Pre-Build Command Line))
  • enter the following command:
    xcopy $(ProjectDir)$(TargetFileName).config /YR

this will copy the [tests.dll].config file to the (Release or Debug) bin folder

Assumptions:
  • This advice applies to VS2003, it is probably very similar for VS2005 but I've not tried it (in fact, if I remember correctly, VS2005 has a much more intuitive method for copying files into the bin directory at build time which won't need an xcopy command...)
  • Your unit tests reside in their own Class Library project
UPDATE: Jamie Cansdale has also now posted on this topic
Friday, February 17, 2006 4:12:52 PM (GMT Standard Time, UTC+00:00)  #    Comments [0] -
TDD
All comments require the approval of the site owner before being displayed.
Name
E-mail
(will show your gravatar icon)
Home page

Comment (Some html is allowed: a@href@title, strike) where the @ means "attribute." For example, you can use <a href="" title=""> or <blockquote cite="Scott">.  

Enter the code shown (prevents robots):

Live Comment Preview
Archive
<August 2008>
SunMonTueWedThuFriSat
272829303112
3456789
10111213141516
17181920212223
24252627282930
31123456
About the author/Disclaimer

Disclaimer
The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.

© Copyright 2008
Rohan Cragg
Sign In
Statistics
Total Posts: 24
This Year: 0
This Month: 0
This Week: 0
Comments: 41
Themes
Pick a theme:
All Content © 2008, Rohan Cragg
DasBlog theme 'Business' created by Christoph De Baene (delarou)