Managed World

Techno-babble from yet another babbler RSS 2.0
# Saturday, April 29, 2006
This kind of bit me in the bud for a while here at home, so I thought I would throw this out in case any others are having the same problem. The symptom was even though I had a setup method decorded with the "SetUp" NUnit attribute, the method wasn't being executed by TestDriven.NET.

Luckily, I don't believe this is an issue with TestDriven.NET as it as an unfortunate side effect with the new C# class templates in VS2005. By default, when you create a new class in VS2005 (at least for me), the class is simply declared as "class MyClass" rather than "public class MyClass". That is what is causing the failure. Once you change the scope of the class to be public, TestDriven.NET will now start running the Setup method as expected.

When you think about it the behavior makes sense. But it is frustrating nonetheless :).
Posted in Programming
 #       Comments [2]
Saturday, April 29, 2006 3:12:33 PM (Pacific Standard Time, UTC-08:00)
This is incredibly annoying from VS.
I keep forgetting to do this.
Saturday, April 29, 2006 8:35:24 PM (Pacific Standard Time, UTC-08:00)
Ayende, you can correct this yourself if you want to :). If you go into the following folder, you will find a zip file containing the template used when create a new class file in C#: "C:\Program Files\Microsoft Visual Studio 8\Common7\IDE\ItemTemplates\CSharp\1033" (in a default installation for Visual Studio 2005). Change the .cs template file in the zip file to include the word "public" if you wish (I also have mine including the CPL license header for my public works), and delete the extracted zip from the "C:\Program Files\Microsoft Visual Studio 8\Common7\IDE\ItemTemplatesCache\CSharp\1033" folder. Upon restart, VS2005 will re-extract the zip file with your new template and you shouldn't have to worry about it anymore :).
Name
E-mail
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">.  

Live Comment Preview

Contact

Email Me Send mail to the author(s)

Calendar

<October 2008>
SunMonTueWedThuFriSat
2829301234
567891011
12131415161718
19202122232425
2627282930311
2345678

About this site

Jason Olson's thoughts on Programming, Games, Music and Life in General

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

© Copyright 2008
Jason Olson

Sign In
All Content © 2008, Jason Olson
Theme based on 'Business' created by Christoph De Baene (delarou)