You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ant.apache.org by Jesse Glick <je...@sun.com> on 2006/03/01 17:44:06 UTC
Re: svn commit: r381780 - in /ant/core/trunk: WHATSNEW docs/manual/OptionalTasks/junit.html
src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTestRunner.java
src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitVersionHelper.java
Martijn Kruithof wrote:
> Isn't this a bit premature, junit 4 isn't even "out" yet.
Seems junit.org has not announced it, but it's there for download and
semi-announced at http://sourceforge.net/projects/junit.
> Furthermore I thought junit 4 would get rid of the distinction
> between failure and error, wouldn't we want to remain in-line with
> this new junit behaviour when running junit 4 testcases in an junit 4
> environment?
Possibly. Here's the problem I faced. If you delete the parts of the
patch that deal with failure vs. error, all test failures are reported
to Ant as errors. So you see e.g.
Tests run: 3, Failures: 0, Errors: 2, Time elapsed: 0.037 sec
just because two assertEquals(...) failed. This is pretty confusing
because the test was not misconfigured and the above summary implies it
was. Note that this happens even for JUnit 3 tests run using the
adapter, which is definitely wrong.
The way the task is currently structured it is impossible to make all
errors be failures while retaining JUnit 3 compatibility, since errors
take Throwable and failures only AssertionFailedError.
So I decided to massage it a bit: when running against junit-4.0.jar,
junit.framework.AssertionFailedError (from 3) and
java.lang.AssertionError (used as of 4) are both treated as "failures"
for purposes of reporting. All other throwables are treated as "errors".
Of course it would be most in the spirit of 4 to have failures vs.
errors be reported as always for 3 tests, but report only failures for 4
tests. Would require the task to _not_ use the adapter for a test it can
determine conclusively to be a 3 test (not sure exactly how this is done).
But would not work anyway because JUnitResultFormatter extends
junit.framework.TestListener which does not permit an arbitrary
Throwable to be reported as a failure. Even if we changed the JURF
interface and rewrote the shipped result formatters (plain, brief, XML,
summary) to use a different mechanism we would have broken custom result
formatters, which are supported by the task (and presumably are also
expecting to display both failure and error counts).
So I don't yet see a reasonable way to have results from 4 tests (and
only 4 tests) reported with only a failure count, while continuing to
report failures and errors for 3 tests, and retaining compatibility with
custom formatters. Anyone with an idea, please feel free to fix.
-J.
--
jesse.glick@sun.com x22801 netbeans.org ant.apache.org
http://google.com/search?q=e%5E(pi*i)%2B1
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org