Re: Addin SetUp question
"Charlie Poole" <[email protected]>
| Newsgroups | gmane.comp.windows.dotnet.nunit.devel |
|---|---|
| Message-ID | <001c01c87c88$aa9c8500$6401a8c0@ferrari> |
Hi Kelly, SetUp/TearDown is somewhat unique, since the methods are part of the fixture but executed by the test case. To allow for this, the constructor of NUnitTestMethod gets the setUpMethod and tearDownMethod fields to the MethodInfo for the SetUp and TearDown methods of the FixtureType, if they exist. TestMethod.Run() calls them on the fixture object, which NUnit creates in the parent fixture. Since you are inheriting from NUnitTestMethod, which in turn inherits from TestMethod, this should just work. However, I have a strong suspicion that your setup may be executed on a different instance of the fixture class from the one that is used in running the test. This might happen because you have interposed a TestSuite in the hierarchy of tests between the TestFixture and your IterativeTestCase. Test cases assume that their parent in the hierarchy is a TestFixture and go to that parent to find the already instantiated object. Since TestSuite doesn't have an object, the result is null. However, to allow NUnit's own tests to execute TestMethods independently, there is code there to create the object if it doesn't already exist. You may need to debug through this to see what is happening, or perhaps you could write a test. :-) I'll give some thought about how to handle this situation, where the "natural parent" of a test is different from it's parent in the tree. Charlie > -----Original Message----- > From: [email protected] > [mailto:[email protected]] On > Behalf Of Kelly Anderson > Sent: Friday, February 29, 2008 5:00 PM > To: [email protected] > Subject: [nunit-developer] Addin SetUp question > > I'm running my IterativeTest Addin under TestDriven.NET in > the debugger. I'm noticing that it's not calling the SetUp > function before running each test. I would assume that the > RowTest extension isn't doing this either. Is this something > that the Addin has to do? Or is it something that the NUnit > core is supposed to do... I'm not sure what should happen, > but I'm thinking that the SetUp should be called prior to > each individual test, however, it doesn't seem to be. I > suppose it could be a TestDriven.Net thing, but I'm noticing > behaviors from the NUnit GUI that would indicate the same > thing is happening. > > What is the relationship to the SetUp attribute on a class > and the way the Addins work? > > -Kelly > > -------------------------------------------------------------- > ----------- > This SF.net email is sponsored by: Microsoft Defy all > challenges. Microsoft(R) Visual Studio 2008. > http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ > _______________________________________________ > nunit-developer mailing list > [email protected] > https://lists.sourceforge.net/lists/listinfo/nunit-developer > ------------------------------------------------------------------------- This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/