Oops, forgot about your "static". It's the same : if one of your tests modifies the static, then for the same reason, in next test the value should be kept...
On Tue, 7 Dec 2004 13:18:57 +0100, Thibaut BarrÃre <[EMAIL PROTECTED]> wrote: > Hi Steve > > did you intented to post this to NUnit rather than NAnt-Users ? > > Afaik in a nunit testfixture, isolation between tests in the same > testfixture is not achieved by the framework, which means if you have > another test which initialize your hashtable and do not set back the > hashtable to null in a [teardown], it will stay allocated, hence your > breakpoint detects a non null value. Actually only one instance of the > testfixture is instanciated, then setup/test/teardown are called on > the very same instance for each test, as far as I have understood. > Which leads to what you get. > > I'm not sure it's a bug or really by design, but I was clearly > surprised just like you. > > To work around that, I carefully Dispose or set to null all the > objects I use in the TearDown. > > Have a look at Martin bliki on this topic : > http://www.martinfowler.com/bliki/JunitNewInstance.html > > cheers > > Thibaut BarrÃre > http://blogs.dotnetguru.org/tbarrere > > On Mon, 6 Dec 2004 18:02:38 -0800, Steve Burkett > > > <[EMAIL PROTECTED]> wrote: > > > > > > > > Hello everyone, > > > > > > > > Has anyone seen a problem like this? (this is a contrived example of the > > problem) > > > > > > > > For some strange reason, when I stop the debugger at BP #1, for the first > > time, table_ is **already initialized to a Hashtable, count = 0 (when it > > should be null, and thus step into using the new operator. > > > > > > > > Any ideas? > > > > > > > > > > > > > > > > â > > > > > > > > static private Hashtable table_ = null; > > > > > > > > public static Hashtable t > > > > { > > > > get > > > > { > > > > if ( table_ == null ) //BP #1 > > > > { > > > > table_ = new Hashtable(); > > > > } > > > > return table_; > > > > } > > > > } > > > > > > > > /// <summary> > > > > /// </summary> > > > > [Test] > > > > public void TestExecuteReader() > > > > { > > > > Hashtable temp = t; > > > > â > ------------------------------------------------------- SF email is sponsored by - The IT Product Guide Read honest & candid reviews on hundreds of IT Products from real users. Discover which products truly live up to the hype. Start reading now. http://productguide.itmanagersjournal.com/ _______________________________________________ Nant-users mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/nant-users
