1) Ignore Exception thrown by
junit.framework.TestCase#tearDown method if
junit.framework.TestCase#runTest fails :
--- src/junit/extensions/abbot/ResolverFixture.java~
2005-10-05 13:59:57.958348500 +0200
+++ src/junit/extensions/abbot/ResolverFixture.java
2005-10-14 14:33:46.298881700 +0200
@@ -88,7 +88,7 @@
Throwable exception = null;
fixtureSetUp();
try {
- super.runBare();
+ enhancedRunBare();
}
catch(Throwable e) {
exception = e;
@@ -107,6 +107,27 @@
throw exception;
}
+ private void enhancedRunBare() throws Throwable {
+ Throwable throwable = null;
+ setUp();
+ try {
+ runTest();
+ } catch ( Throwable t ) {
+ throwable = t;
+ } finally {
+ try {
+ tearDown();
+ } catch ( Exception e ) {
+ if ( null == throwable ) {
+ throwable = e;
+ }
+ }
+ }
+ if ( null != throwable ) {
+ throw throwable;
+ }
+ }
+
/** Construct a test case with the given name. */
public ResolverFixture(String name) {
super(name);
2) Make possible to customize Exception handling in
ComponentTestFixture
---
src/junit/extensions/abbot/ComponentTestFixture.java~
2005-10-05 13:59:57.942727700 +0200
+++
src/junit/extensions/abbot/ComponentTestFixture.java
2005-10-14 14:47:54.574221700 +0200
@@ -385,16 +398,22 @@
// Any EDT exception which occurred
*prior* to when the
// exception on the main thread was thrown
should be used
// instead.
+ exception = ruleOut( exception,
exceptionTime, edtException, edtExceptionTime );
+ }
+ if (exception != null) {
+ throw exception;
+ }
+ }
+
+ protected Throwable ruleOut( Throwable exception,
long exceptionTime,
+ Throwable edtException, long
edtExceptionTime ) {
if (edtException != null
&& (exception == null
|| edtExceptionTime <
exceptionTime)) {
// TODO wrap this somehow with an
additional message that
// says "this was thrown on the EDT"
- exception = edtException;
- }
- }
- if (exception != null) {
- throw exception;
+ return edtException;
}
+ return exception;
}
}
Cause we would like to use the following strategy in
our custom subclass :
protected Throwable ruleOut( Throwable exception,
long exceptionTime,
Throwable edtException, long
edtExceptionTime ) {
if ( null != edtException ) {
if ( null == exception ) {
exception = edtException;
} else if ( null == exception.getCause() ) {
exception.initCause( edtException );
} else {
if ( edtExceptionTime < exceptionTime ) {
exception.printStackTrace();
exception = edtException;
} else {
edtException.printStackTrace();
}
}
}
return exception;
}
Logged In: YES
user_id=54098
The behavior you're referring to in item #1 (tearDown exceptions obscuring
runTest exceptions) was fixed in version 1.16 of TestCase.java in the junit
CVS tree (I'm not sure what junit releaes that corresponds to). That
change was made around 14 months ago, and the abbot fixtures behave in
a similar fashion.
Please rephrase the goal of item #2 in plain english.
Logged In: YES
user_id=1312539
This Tracker item was closed automatically by the system. It was
previously set to a Pending status, and the original submitter
did not respond within 14 days (the time period specified by
the administrator of this Tracker).