log4j messages out of order w.r.t JUnit under Ant?

B

bugbear

Being a conventional sort of soul, I'm using
Ant as my build tool, Log4j as my logging tool
and JUnit as my test harness.

When a JUnit test fails unexpectedly (typically
with an Exception), I would like to enable
some logging, to see the events and actions
that build up to the problem, allowing
rapid (hah!) diagnosis and fixing.

But the messages from Log4J are not
merged nicely with the messages from JUnit
in the output files.

It looks like some kind of buffering problem,
a bit like you get when you capture both
stdout and stderr to the same file under *nix.

Can anyone help?

BugBear
 
C

Chris

Your assumption is correct.

I don't know if there is any way or stopping Log4J / Junit
inter-leaving their output (or any other combo of output streams for
that matter).

I'd suggest sending your log output to a file instead (presumably you
only need to look at it if one of your tests fails anyway?)

- sarge
 
B

bugbear

Your assumption is correct.

I don't know if there is any way or stopping Log4J / Junit
inter-leaving their output (or any other combo of output streams for
that matter).

I *want* inter-leaving. I *want* perfect, line-by-line
inter-leaving. Because what I want is detailed logging
just *before* JUnit reports failure. If there is more
than one test in your testsuite you tend to get all the Log4J
messages, and then all the JUnit failure reports, rendering
it difficult (and tiresome, and tedious etc) to make a useful
1:1 mapping between the two.

If I could turn off all buffering it would give me the output
I want, although possibly the performance would suffer.

BugBear
 
C

Chris

I *want* inter-leaving. I *want* perfect, line-by-line
inter-leaving. Because what I want is detailed logging
just *before* JUnit reports failure. If there is more
than one test in your testsuite you tend to get all the Log4J
messages, and then all the JUnit failure reports, rendering
it difficult (and tiresome, and tedious etc) to make a useful
1:1 mapping between the two.

Then a better solution would be to run only the test(s) that are
failing. There's no point dumping all the log output for tests that
work, or repeatedly running passed tests when you're trying to sort
out the broken ones.

When fixing tests using Junit/ANT I run single test-case classes or
even an individual test method rather than the lot.

The following java.net article outlines how to do this nicely:

http://today.java.net/pub/a/today/2003/09/12/individual-test-cases.html?page=last

Hope this helps.

- sarge
 
B

bugbear

Then a better solution would be to run only the test(s) that are
failing. There's no point dumping all the log output for tests that
work, or repeatedly running passed tests when you're trying to sort
out the broken ones.

When fixing tests using Junit/ANT I run single test-case classes or
even an individual test method rather than the lot.

The following java.net article outlines how to do this nicely:

http://today.java.net/pub/a/today/2003/09/12/individual-test-cases.html?page=last

Hope this helps.

I think it will.

It addresses my principal problem, and renders
my actual question (about line buffering and stuff)
irrelevant.

I guess this is the very best kind
of topic drift :)

Bugbear
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top