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
Archive
<February 2006>
SunMonTueWedThuFriSat
2930311234
567891011
12131415161718
19202122232425
2627281234
567891011
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)