db-derby-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dyre.Tjeldv...@Sun.COM
Subject Re: How to output debug messages in test cases?
Date Fri, 29 Feb 2008 10:12:15 GMT
Dibyendu Majumdar <dibyendu@mazumdar.demon.co.uk> writes:

> Hi,
> I have a very basic query. I want to put in some debug messages in
> Derby classes and see the output as I run some Junit test cases?
> How do I do this?
> Sending messages to stderr seems to cause tests to fail.

Unfortunately, stderr goes to the same place as stdout, so writing to
stderr will break all canon-based tests (most tests in the old harness
and some JUnit tests). There are a couple of things that you can do,
depending on which part of the code you are in, and what you need to do:

On the server, you can use the Monitor.logMessage system to write
messages directly to derby.log. You can also use the 
SanityManager.DEBUG_ON("mydebugflag") predicate if you only want to/need
to see the debug when you run with that flag.

In the client you can use the agent.trace() system which will log to a
separate trace file.

Inside the JUnit test case you can use the println() method which only
will print something if a certain property (I forget the name) is set to
true. (Setting this will not break canon-based tests).



View raw message