db-derby-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Knut Anders Hatlen <Knut.Hat...@Sun.COM>
Subject Re: [JUnit] Should assertSQLState throw SQLException?
Date Sat, 26 Aug 2006 10:46:21 GMT
Daniel John Debrunner <djd@apache.org> writes:

> Kristian Waagan wrote:
>
>
>> Any suggestions on how we can achieve what Knut Anders is proposing?
>> I think it is a good proposal to preserve the stack trace, the error
>> message and the SQL state.
>
> I think we want to do something like this (which requires JDK 1.4 or
> higher), I'm looking at implementing this and maybe just lose the error
> in jdk1.3.
>
>
>         } catch (AssertionFailedError e) {
>
>             // Save the SQLException
>             e.initCause(exception);
>
>             throw e;
>         }
>
> around the asserts in assertSQLState() (except for assertion that
> exception is not null)
>
> This will save the stack trace.

Sounds good to me. I don't think it's a big issue that we lose the
error in jdk1.3.

> This could be followed on by code in BaseTestCase.runBase to always
> print the exception, or to save the exception's stack trace in the newly
> added "failed" folder (see BaseTestCase.getFailedFolder()).
>
> I don't think individual tests should be trying to print stack traces,
> if we can centralize it then we will end up with consistent results.
> E.g. well formatted information about SQLExceptions including the
> chaining. Having each test print exceptions will mean endless variety as
> to how they are printed and most missing the chain of exceptions. That's
> what happens today with the existing tests.

I agree. Thank you for all your hard work on the JUnit framework!

-- 
Knut Anders

Mime
View raw message