ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Stefan Bodewig <bode...@apache.org>
Subject Re: Introducing AntUnit
Date Thu, 14 Apr 2005 14:16:08 GMT
On Thu, 14 Apr 2005, Paul King <king@asert.com.au> 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() {
        executeTarget("test4");
        assertTrue(project.getProperty("test") == null);
    }

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

with

  <target name="test4">
    <available property="test" 
               file="src/etc/testcases/taskdefs/this_file_does_not_exist"/>
  </target>

  <target name="test5">
    <available property="test" 
               file="available.xml"/>
  </target>

This would then simply become a build file looking like

  <target name="test4">
    <available property="test" 
               file="src/etc/testcases/taskdefs/this_file_does_not_exist"/>
    <au:assertPropertyNotSet name="test"/>
  </target>

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

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
trivial:

<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 (webtest.canoo.com).

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.

Stefan

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org


Mime
View raw message