You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-dev@db.apache.org by Dibyendu Majumdar <di...@mazumdar.demon.co.uk> on 2008/02/29 01:12:22 UTC

How to output debug messages in test cases?

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.

Regards 

Re: How to output debug messages in test cases?

Posted by Dy...@Sun.COM.
Dibyendu Majumdar <di...@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).

HTH,

-- 
dt