The Artima Developer Community
Sponsored Link

SuiteRunner Forum
What to Do When setUp/tearDown Throw Exceptions?

3 replies on 1 page. Most recent reply: Mar 6, 2003 5:35 AM by Clark Updike

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 3 replies on 1 page
Bill Venners

Posts: 2284
Nickname: bv
Registered: Jan, 2002

What to Do When setUp/tearDown Throw Exceptions? Posted: Mar 4, 2003 12:24 AM
Reply to this message Reply
Advertisement
I've been working on improving the behavior of executeTestMethods when exceptions get thrown from setUpFixture, tearDownFixture, and test methods, and clarifying the documentation. I'd like to ask people's opinions.

If setUpFixture throws an exception, should we not just abort execution of that entire set of test methods? Because I don't think it makes sense to invoke the test method, and it doesn't make sence to invoke tearDownFixture. That means the next thing to invoke would be setUpFixture again prior to invoking the next test method. But it just failed, so it will probably fail again.

If setUpFixture succeeds, but tearDownFixture fails, I don't feel as clear as to the correct behavior. But I'm leaning towards just aborting the entire execution of the test methods of that Suite. It is conceivable that something needs to be done in tearDownFixture for the subsequent test methods to work correctly. Also, aborting the execution of all remaining test methods would be consistent with what we do when setUpFixture throws an exception. So we could say:

If setUpFixture returns normally, tearDownFixture will be called even if the test method completes abruptly with an exception. But if either setUpFixture or tearDownFixture completes abruptly with an exception, the executeTestMethods method will report the problem and abort. It will not attempt to execute any subsequent test methods.

Sound reasonable?


Andrew Matthews

Posts: 9
Nickname: taxman
Registered: Feb, 2003

Sounds reasonable Posted: Mar 4, 2003 10:44 AM
Reply to this message Reply
This sounds reasonable to me. One other possibility would be to define this as the default behavior but provide some mechanism for customizing how/when/if setUpFixture and tearDownFixture will be executed.

Bill Venners

Posts: 2284
Nickname: bv
Registered: Jan, 2002

Re: Sounds reasonable Posted: Mar 4, 2003 4:38 PM
Reply to this message Reply
We already did that. You can customize the default behavior by overriding executeTestMethods.

Clark Updike

Posts: 11
Nickname: clark
Registered: Apr, 2002

Re: Sounds reasonable Posted: Mar 6, 2003 5:35 AM
Reply to this message Reply
And don't forget, you can always wrap all the code in your setUpFixture & tearDownFixture methods in try/catch blocks and consume (by not rethrowing) any exceptions in the catch block--probably easier than overriding executeTestMethods. So I'd vote to have exceptions terminate the suite from either method and then the test writer can consume them in either method if needed.

Flat View: This topic has 3 replies on 1 page
Topic: Artima SuiteRunner version 1.0beta6 Released Previous Topic   Next Topic Topic: Bug report? Suites with more than 20 test methods in them seem to hang.

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use