I would mostly encourage this. It would seem reasonable to be able to write tests productively use ant build files. I am not sure how directly tied to ant (vs testing any java program) you would need to make it to be worthwhile. I would hope that it could be more generic.
You might want to have a look at webtest (webtest.canoo.com). It is designed for testing web applications but might be a fruitful source of ideas. Webtest uses webtest tests (along with java unit tests) for its self-tests.
Paul.
Stefan Bodewig wrote:
Hi,
inspired by the creative use of <macrodef> and <fail> others (mainly Matt and Steve) have shown in our tests, the idea of AntUnit we had a long time ago surfaced in my mind again.
I've just dumped a little macrodef antlib (and one "real" task, <assertTrue>) into our proposal area. This is only a temporary place until my JIRA request for a subversion space for Ant[1] has been answered.
I simply lost patience and didn't want to have the code on my disk until the next head-crash. And I also don't know when I'll find time to continue work on it, so I wanted to give others a chance to play with it.
The idea is to create a unit test Ant library that uses Ant build files to test Ant. Having assert tasks is only one part of it and it pretty much works the way that I've already shown (a very incomplete list of asserts we'll need is in antlib.xml). Things like assertLogContaining will be more difficult to do.
The other part will be an <antunit> task, which will take a build file and for each target whose name starts with "test" will
(1) create an Ant task (2) run the target named setUp if present (3) run the target (4) run the target named tearDown if present
It will support result formatters much like the JUnit task. There will be passing and failing tests as well as tests that cause errors. To tell failures from errors, <assert*> throws a subclass of BuildException named AssertionFailedException.
It may be better to fork a new VM, I'm not sure. Reusing the Ant task would certainly be easier.
What do you think? Is this worth the effort?
I came accross some issues that I'm going to raise in separete threads.
Stefan
Footnotes: [1] http://issues.apache.org/jira/browse/INFRA-263
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
-- Managing Director & Principal Consultant, ASERT Consulting Pty Ltd Specialists in Java/J2EE, XML, Internet, Integration, Content Management Level 3, Suite 10/53 Tribune Street, South Brisbane Qld Australia 4101 tel: 07 3844 1344, fax: 07 3844 1099, mob: 0404 012 062 web: http://www.asert.com.au, email: [EMAIL PROTECTED] ---------------------------------------------------------------------- This message is intended solely for the named addressee and may contain privileged & confidential information. Copying or distribution of this transmission or any information it contains, by anyone other than the addressee, is prohibited. If you receive this message in error please reply to the sender, delete the message and destroy any printed copies. Any views expressed in this message are those of the individual sender. -----------------------------------------------------------------------
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]