ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Stefan Bodewig <>
Subject Re: Introducing AntUnit
Date Thu, 14 Apr 2005 14:16:08 GMT
On Thu, 14 Apr 2005, Paul King <> wrote:

> It would seem reasonable to be able to write tests productively use
> ant build files.

Its main purpose should be to test Ant or Ant tasks.  It would be easy
to rewrite larger parts of Ant's own JUnit tests that way - almost
every Unit test that extends BuildFileTest, at least that's the idea.

Looking into the test for the available task, there are things like

    // file doesn't exist -> property 'test' == null
    public void test4() {
        assertTrue(project.getProperty("test") == null);

    // file does exist -> property 'test' == 'true'
    public void test5() {
        assertEquals("true", project.getProperty("test"));


  <target name="test4">
    <available property="test" 

  <target name="test5">
    <available property="test" 

This would then simply become a build file looking like

  <target name="test4">
    <available property="test" 
    <au:assertPropertyNotSet name="test"/>

  <target name="test5">
    <available property="test" 
    <au:assertPropertyEquals name="test" value="true"/>

and no Java code at all.

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

Quite possibly so, even though I don't see any direct impact.  Things
like testing the external results of a java application would be

<java classname="...">
<au:assertFileExists ...>

if you want to assert that a certain appliaction creates a file, but
Ant probably is a bit limited here, since it couldn't test at the
method level.

It may be useful as a functional test environment rather than unit
tests, which may lead us to pick a different name.

> You might want to have a look at webtest (

I know it (I even provided a patch to make it work with Ant 1.6 ;-).

> It is designed for testing web applications but might be
> a fruitful source of ideas.

True, I'll have a second look at it.


To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message