ant-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject DO NOT REPLY [Bug 44530] junit task with forkmode=once and xml formatter does not save all system.out
Date Thu, 17 Nov 2011 00:54:58 GMT
https://issues.apache.org/bugzilla/show_bug.cgi?id=44530

--- Comment #4 from Eric Anderson <ejona@google.com> 2011-11-17 00:54:58 UTC ---
I just implemented a workaround for this bug in my own codebase by using a
formatter created for the task (a la
org.apache.tools.ant.taskdefs.optional.junit.TearDownOnVmCrash). My workaround
is for users of java.util.logging.

The code for the formatter is available at (I'll add it as an attachment as
well):
http://code.google.com/p/plexi/source/browse/test/JUnitLogFixFormatter.java

Use it by adding an additional formatter tag to your build.xml:

<junit...
  ...
  <formatter classname="JUnitLogFixFormatter" usefile="false"/>
  ...
</junit>


At the beginning of each test, the code looks at the root Logger and replaces
any ConsoleHandlers it finds with a new ConsoleHandler (and copies over the
configuration). ConsoleHandler caches System.err during its constructor, so
constructing a new instance is required. After the test completes, the original
handlers are replaced back into the root Logger.

For my codebase this seems to work, but YMMV.

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

Mime
View raw message