ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Stefan Bodewig <>
Subject The JUnit task
Date Thu, 20 Jul 2000 10:50:13 GMT
The task I've just commited is Thomas' version with some minor and one
rather big change. The latter will probably break Thomas' own system
but we should find another solution for that.

Thomas had a logic in place that wouldn't run a testcase if Ant knew
this one had succeeded sometime earlier. It detected this by searching
for a file TEST-classname.xml - if it was present, the test was
skipped. Such a file would be generated each time a test was run

The only way you could ensure all your tests would run was to remove
the TEST-* files manually. At least I cannot find a simple logic to
ensure that the TEST- file was actually newer than the class file of
the testcase and all class files of all units the test relied on.

I've commented out the parts responsible for this completely (search
for "removed --SB" in JUnitTask) - so Ant will run all tests specified
without thinking about prior results.

The typical syntax is

  <test name="classname" />

There are a couple of attributes to junit as well as to test.


* defaulthaltonerror, defaulthaltonfailure you can stop the tests and
the build process on errors or unittest failures. Both can be
overridden on a test by test basis.

* defaultprintsummary Print something like 
Tests run: 16, Failures: 0, Errors: 0, Time elapsed: 0,067 sec
after each test. Can be overridden on a test by test basis.

* defaultprintxml Print an XML file with detailed information about
the test results. See below. Can be overridden on a test by test basis.

* defaultoutfile. A boolean that will set the output of all tests to
TEST-classname.xml if not overridden by the test's outfile
attribute. See below.

* fork - like in <java>. Actually it doesn't work too well without fork
- this will be improved by using Conor's classloader. Can be set on a
test by test basis.

* junit - CLASSPATH part for JUnit. Works together with the nested
classpath attribute. Has no meaning if fork is off.

* timeout - same as the attribute to the new exec task.

* jvmargs - whatever you need to provide as additional arguments:
-Djava.compiler=NONE -Xmx1024m or so.


* name - classname of the unittest.

lot's of attributes that override the defaults set on the junit

I'd like to restructure this a little. XMLJUnitResultFormatter is the
class responsible for writing the XML output. This one implements the
interface JUnitResultFormatter. The actual TestRunner can handle
arbitrary implementations of this interface. 

So instead of the printxml and outfile attributes I'd like to have a

<formatter classname="..." out="..." />

element. This would give a much larger flexibility to the user - write
your own formatter for test results - and don't bother Ant's core with
it. We could keep the XML version (as is or modified) as a simple
supplied version, maybe together with a plain text one.

Feedback is welcome and I'll wait for comments before I proceed.


View raw message