ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Scott Stirling" <>
Subject [PATCH - update] JUnit optional task - stack trace filtering
Date Sat, 08 Dec 2001 04:26:22 GMT
This patchfile supersedes the one I sent yesterday.  I updated the JUnitTestRunnerTest unit
test and applied stack trace filtering
to the BriefResultFormatter (I'd previously only modified the plain and xml formatters).

Some minor fixes as side effects of going through the code:
- changed "tags" to "attributes" in description of errorProperty and failureProperty at bottom
of junit.html

- remove extra colon in BriefResultFormatter formatError output

- fix misassignment in JUnitTest constructor for haltOnFailure parameter

- Javadoc comment typo in JUnitTask.init()


Scott Stirling
Framingham, MA

**** Original message ****
I modified the Ant JUnit task to support the JUnit feature that filters stack frames in failure
and error messages so that
junit.framework method frames don't clutter your exception traces.  I added filtering for as well.  Unless you
are testing Ant or JUnit itself, you really don't need to see any of those junit.framework.*
stack frames in an exception trace.

Patchfile is attached, which includes updates to the junit.html doc page.

Like the filter in JUnit, it is not configurable, other than to turn it off/on.
It could be, but I think the intended purpose is pretty well achieved with the
default set of patterns (see the patchfile for the list of excluded patterns).

To use it in a build.xml, do nothing; the filtering is enabled by default.  To
disable it, just add the attribute filtertrace="false" to your junit, batchtest or
test task element, e.g.:

<junit printsummary="yes" filtertrace="false" dir="${basedir}/lib" haltonerror="${qa.junit.haltonerror}"
haltonfailure="${qa.junit.haltonfailure}" fork="yes">

Here is an example of the before and after versions of a filtered AssertionFailedError run
in Ant:

Original, unfiltered output you get with Ant:

at junit.framework.Assert.assertTrue(
at junit.framework.Assert.assertNotNull(
at junit.framework.Assert.assertNotNull(
at test.jrunx.persistence.DatabaseTest.setUp(
at junit.framework.TestCase.runBare(
at junit.framework.TestResult$1.protect(
at junit.framework.TestResult.runProtected(
at junit.framework.TestSuite.runTest(

With filtertrace enabled:

at test.jrunx.persistence.DatabaseTest.setUp(

I hope the maintainers of the JUnit task will vote for inclusion of this patch.  We find it
very useful at work (I work on JRun at
Macromedia), as it condenses our JUnit reports considerably (if there are errors/failures).


Scott Stirling
Framingham, MA

View raw message