Re: Run TestFixtureTearDown even if TestFixtureSetupfails?

"J M Oudesluys" <[email protected]>
Newsgroups gmane.comp.windows.dotnet.nunit.user
Message-ID <[email protected]>
Hi Rocco.  Thanks for the reply.

The design pattern, of course, makes sense.  Reviewing my teardown
method, there are situations where a setup error could cause
exceptions to be thrown when attempting my cleanup (not what I want at
all).  I've instead wrapped my setup code in a try..finally block,
where I can test for setup success and state before doing any needed
cleanup.

- Jocelyn

On 06/12/2007, Rocco Pigneri <[email protected]> wrote:
> Jocelyn,
>
> I actually ran into this situation as well.  The idea behind the framework's
> behavior is that if the setup fails, then it doesn't make sense to run the
> tear down because there are no guarantees about the state of setup since
> there was an error.
>
> In my case, I was having trouble with the test setups failing when trying to
> put data in the database that was not deleted from the last run because the
> setup failed and the tear down never ran.  In this case, I just put the
> tear-down code in the setup before the actual setup code in order to ensure
> that the setup would always run successfully.
>
> Hope that helps,
>
> Rocco
>
> -----Original Message-----
> From: [email protected]
> [mailto:[email protected]] On Behalf Of J M
> Oudesluys
> Sent: Thursday, December 06, 2007 11:22 AM
> To: [email protected]
> Subject: [Nunit-users] Run TestFixtureTearDown even if
> TestFixtureSetupfails?
>
> Is there a way to force a TestFixtureTearDown method to run even if
> TestFixtureSetUp fails?  I have objects created and initialized in my
> setup that need to be cleaned up even if the initialization fails, but
> I can't seem to find any attributes or settings that would allow me to
> do this.
>
> - Jocelyn
>
> -------------------------------------------------------------------------
> SF.Net email is sponsored by: The Future of Linux Business White Paper
> from Novell.  From the desktop to the data center, Linux is going
> mainstream.  Let it simplify your IT future.
> http://altfarm.mediaplex.com/ad/ck/8857-50307-18918-4
> _______________________________________________
> Nunit-users mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/nunit-users
>
>

-------------------------------------------------------------------------
SF.Net email is sponsored by: The Future of Linux Business White Paper
from Novell.  From the desktop to the data center, Linux is going
mainstream.  Let it simplify your IT future.
http://altfarm.mediaplex.com/ad/ck/8857-50307-18918-4
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.