db-derby-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Daniel John Debrunner <...@apache.org>
Subject Re: [JUnit] Should assertSQLState throw SQLException?
Date Thu, 24 Aug 2006 23:54:15 GMT
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

            throw e;

around the asserts in assertSQLState() (except for assertion that
exception is not null)

This will save the stack trace.

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.


View raw message