You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ant.apache.org by Scott Stirling <sc...@rcn.com> on 2001/12/07 08:16:20 UTC

[PATCH] JUnit optional task - stack trace filtering

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]

Re: [PATCH] JUnit optional task - stack trace filtering

Posted by Stefan Bodewig <bo...@apache.org>.
On Fri, 7 Dec 2001, Steve Loughran <st...@iseran.com> wrote:

> Filtering needs to be off by default so anything which tries to
> interpret the trace now wont break.

If it is "on" by default, we should at least put a warning into
WHATSNEW.  I'm not sure whether projects like CruiseControl rely on
full stack traces.

We will have to switch filtering off in Ant's own build file, off
course (as would the JUnit people if they were using the junit task).

Stefan

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: [PATCH] JUnit optional task - stack trace filtering

Posted by Erik Hatcher <ja...@ehatchersolutions.com>.
I believe the only effect would be a shorter stack trace output, and that is
all.  Is that correct Scott?

What automated test systems are you speaking of that would be interpreting
the trace?

    Erik


----- Original Message -----
From: "Steve Loughran" <st...@iseran.com>
To: "Ant Developers List" <an...@jakarta.apache.org>
Sent: Friday, December 07, 2001 9:29 PM
Subject: Re: [PATCH] JUnit optional task - stack trace filtering


> that's enough cash to buy my vote, at least for a non controversial issue,
> though Monsiuer Baillez has effective control over the Junit stuff so I'll
> leave the final decision to him.
>
> What would the effect of this change be on automated tests systems?
> Filtering needs to be off by default so anything which tries to interpret
> the trace now wont break.
>
> -steve
>
>
>
> ----- Original Message -----
> From: "Erik Hatcher" <ja...@ehatchersolutions.com>
> To: "Ant Developers List" <an...@jakarta.apache.org>
> Sent: Friday, December 07, 2001 5:48 PM
> Subject: Re: [PATCH] JUnit optional task - stack trace filtering
>
>
> > Excellent!
> >
> > I put my $0.02 in for this patch.
> >
> >     Erik
> >
> >
> > ----- Original Message -----
> > From: "Scott Stirling" <sc...@rcn.com>
> > To: <an...@jakarta.apache.org>
> > Sent: Friday, December 07, 2001 2:16 AM
> > Subject: [PATCH] JUnit optional task - stack trace filtering
> >
> >
> > > 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(JUnitTestRu
> > nner.java:252)
> > > at
> >
>
org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.main(JUnitTestR
> > unner.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]
> > >
> >
> >
>
> --------------------------------------------------------------------------
> --
> > ----
> >
> >
> > > --
> > > To unsubscribe, e-mail:
> <ma...@jakarta.apache.org>
> > > For additional commands, e-mail:
> <ma...@jakarta.apache.org>
> >
> >
> > --
> > To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
> > For additional commands, e-mail:
<ma...@jakarta.apache.org>
> >
> >
>
>
> --
> To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>
>
>


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


RE: [PATCH] JUnit optional task - stack trace filtering

Posted by Scott Stirling <sc...@rcn.com>.
> -----Original Message-----
> From: Steve Loughran [mailto:steve_l@iseran.com]

> What would the effect of this change be on automated tests systems?
> Filtering needs to be off by default so anything which tries to interpret
> the trace now wont break.

I take it you mean the Jakarta build systems?  It doesn't affect the functionality of things like haltonfailure or haltonerror, or
anything else except the format of reports.  And it does not filter out lines with junit.framework.AssertionFailedError, nor does it
filter with the BriefJUnitResultResultFormatter, which is what's currently used in the Ant build.  I never use the brief formatter,
so I didn't change it.  I could though (should have).

I'm glad you asked, because I just ran the Ant unit tests and found a compiler error that needs to be fixed in the
JUnitTestRunnerTest because I changed the constructor signature for JUnitTestRunner.

I just made the same filtering modification to the brief formatter and fixed the JUnit test case and am going to resubmit a new
patchfile in a minute.

Best,

Scott Stirling
Framingham, MA

>
> -steve


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: [PATCH] JUnit optional task - stack trace filtering

Posted by Steve Loughran <st...@iseran.com>.
that's enough cash to buy my vote, at least for a non controversial issue,
though Monsiuer Baillez has effective control over the Junit stuff so I'll
leave the final decision to him.

What would the effect of this change be on automated tests systems?
Filtering needs to be off by default so anything which tries to interpret
the trace now wont break.

-steve



----- Original Message -----
From: "Erik Hatcher" <ja...@ehatchersolutions.com>
To: "Ant Developers List" <an...@jakarta.apache.org>
Sent: Friday, December 07, 2001 5:48 PM
Subject: Re: [PATCH] JUnit optional task - stack trace filtering


> Excellent!
>
> I put my $0.02 in for this patch.
>
>     Erik
>
>
> ----- Original Message -----
> From: "Scott Stirling" <sc...@rcn.com>
> To: <an...@jakarta.apache.org>
> Sent: Friday, December 07, 2001 2:16 AM
> Subject: [PATCH] JUnit optional task - stack trace filtering
>
>
> > 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(JUnitTestRu
> nner.java:252)
> > at
>
org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.main(JUnitTestR
> unner.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]
> >
>
>
> --------------------------------------------------------------------------
--
> ----
>
>
> > --
> > To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
> > For additional commands, e-mail:
<ma...@jakarta.apache.org>
>
>
> --
> To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>
>
>


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: [PATCH] JUnit optional task - stack trace filtering

Posted by Erik Hatcher <ja...@ehatchersolutions.com>.
Excellent!

I put my $0.02 in for this patch.

    Erik


----- Original Message -----
From: "Scott Stirling" <sc...@rcn.com>
To: <an...@jakarta.apache.org>
Sent: Friday, December 07, 2001 2:16 AM
Subject: [PATCH] JUnit optional task - stack trace filtering


> 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(JUnitTestRu
nner.java:252)
> at
org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.main(JUnitTestR
unner.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]
>


----------------------------------------------------------------------------
----


> --
> To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>