ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Scott Stirling" <scottstirl...@rcn.com>
Subject [PATCH] JUnit optional task - stack trace filtering
Date Fri, 07 Dec 2001 07:16:20 GMT
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
org.apache.tools.ant 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:

junit.framework.AssertionFailedError
at junit.framework.Assert.fail(Assert.java:51)
at junit.framework.Assert.assertTrue(Assert.java:38)
at junit.framework.Assert.assertNotNull(Assert.java:199)
at junit.framework.Assert.assertNotNull(Assert.java:193)
at test.jrunx.persistence.DatabaseTest.setUp(DatabaseTest.java:61)
at junit.framework.TestCase.runBare(TestCase.java:138)
at junit.framework.TestResult$1.protect(TestResult.java:106)
at junit.framework.TestResult.runProtected(TestResult.java:124)
at junit.framework.TestResult.run(TestResult.java:109)
at junit.framework.TestCase.run(TestCase.java:131)
at junit.framework.TestSuite.runTest(TestSuite.java:173)
at junit.framework.TestSuite.run(TestSuite.java:168)
at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.run(JUnitTestRunner.java:252)
at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.main(JUnitTestRunner.java:433)


With filtertrace enabled:

junit.framework.AssertionFailedError
at test.jrunx.persistence.DatabaseTest.setUp(DatabaseTest.java:61)


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).

Best,

Scott Stirling
Framingham, MA
[work: sstirling@macromedia.com]

Mime
View raw message