You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by Clifton Craig <cc...@gbg.com> on 2006/01/21 21:59:09 UTC

Unit test a build

Given my passion for TDD I am now looking for a way to apply unit tests to my 
Ant build files. Is there an easy way or framework I can use?

--------------------------------------------------- 
Clifton C. Craig, Software Engineer
Intelligent Computer Systems -  A Division of GBG
ccc@icsaward.com
ccraig@gbg.com

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


Re: Unit test a build

Posted by Stefan Bodewig <bo...@apache.org>.
On Wed, 25 Jan 2006, Clifton Craig <cc...@gbg.com> wrote:

> I tried your suggestion and it looks like I'm getting somewhere. I
> now get this on the command line:
> 
> Fetching external item into 'trunk/common' svn: REPORT request
> failed on '/repos/asf/!svn/bc/372259/ant/antlibs/common/trunk' svn:
> REPORT of '/repos/asf/!svn/bc/372259/ant/antlibs/common/trunk': 400
> Bad Request (http://svn.apache.org)

Hmm, the common external is using https, I believe.  Maybe svn has
problems with https via your proxy.

> But some stuff has come down.

At least you are missing the "real" build file.  You can use the
common directory from my zip.  Other than that you probably have
everything.

Stefan

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


Re: Unit test a build

Posted by Clifton Craig <cc...@gbg.com>.
Stefan,

I tried your suggestion and it looks like I'm getting somewhere. I now get 
this on the command line:

Fetching external item into 'trunk/common'
svn: REPORT request failed on 
'/repos/asf/!svn/bc/372259/ant/antlibs/common/trunk'
svn: REPORT of '/repos/asf/!svn/bc/372259/ant/antlibs/common/trunk': 400 Bad 
Request (http://svn.apache.org)

But some stuff has come down. I'm not sure if I got everything on that request 
but it looks like a lot. I also downloaded your copy of Antlib. Thanx! I'll 
see if I can get something working.

--------------------------------------------------- 
Clifton C. Craig, Software Engineer
Intelligent Computer Systems -  A Division of GBG
ccc@icsaward.com
ccraig@gbg.com

On Tuesday 24 January 2006 11:50 pm, Stefan Bodewig wrote:
> On Tue, 24 Jan 2006, Clifton Craig <cc...@gbg.com> wrote:
> > Could you or someone knowledgeable help me get my svn client to
> > retrueve the Ant trunk so I can play with Antunit? Thanx!
>
> If all the help others have given didn't work, try
> <http://people.apache.org/~bodewig/antunit.zip>.
>
> Stefan
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> For additional commands, e-mail: user-help@ant.apache.org

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


Re: Unit test a build

Posted by Stefan Bodewig <bo...@apache.org>.
On Tue, 24 Jan 2006, Clifton Craig <cc...@gbg.com> wrote:

> Could you or someone knowledgeable help me get my svn client to
> retrueve the Ant trunk so I can play with Antunit? Thanx!

If all the help others have given didn't work, try
<http://people.apache.org/~bodewig/antunit.zip>.

Stefan

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


Re: Unit test a build

Posted by Clifton Craig <cc...@gbg.com>.
Carp! The snapshot doesn't look like it has the subprojects in it.
On Tuesday 24 January 2006 9:59 am, Nicolas Vervelle wrote:
> Clifton Craig wrote:
> >Stefan,
> >
> >That sounds like exactly what I'm looking for. Only there's one big
> > problem. I'm behind an authenticating HTTP proxy and I can't seem to get
> > my svn client to get through it. Our in office proxy has traditionally
> > caused me such problems and I faced this about a month ago when I was
> > trying to retrieve the FOP trunk. I somehow got it to work then but I'm
> > not sure how. I've never used svn before (asides from my clumsily
> > fumbling and actually getting the FOP trunk). I read somewhere that
> > certain proxies don't handle the extended web-dav commands well or pass
> > them through the way they should. I'm not sure if that's my problem or
> > not. I also read that one solution involved either switching from http to
> > https (or the other way around, I'm not sure). Could you or someone
> > knowledgeable help me get my svn client to retrueve the Ant trunk so I
> > can play with Antunit? Thanx!
>
> There are nightly snapshots available for download:
> http://cvs.apache.org/snapshots/ant/
> So you can get the source code without using svn.
>
> Other idea: maybe there's the possibility to have a web access (html) to
> the repository and a client that can get files from the web access.
> It exists for CVS but I don't know for svn.
>
> Hope this helps
> Nico
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> For additional commands, e-mail: user-help@ant.apache.org

-- 
------------------------------------------------- 
Clifton C. Craig, Software Engineer
Intelligent Computer Systems -  A Division of GBG
ccc@icsaward.com
ccraig@gbg.com

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


Re: Unit test a build

Posted by Stefan Bodewig <bo...@apache.org>.
On Tue, 24 Jan 2006, Clifton Craig <cc...@gbg.com> wrote:

> svn co http://svn.apache.org/viewcvs.cgi/ant/antlibs/antunit/trunk/

remove viewcvs.cgim and replace it with repos/asf

See <http://ant.apache.org/antlibs/proper.html>.

Stefan

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


Re: Unit test a build

Posted by Clifton Craig <cc...@gbg.com>.
This is the error I get on the svn command line:
ccc@ccc:~/neware/subversion/apache-ant-1.6.5$ svn co 
http://svn.apache.org/viewcvs.cgi/ant/antlibs/antunit/trunk/
svn: PROPFIND request failed on '/viewcvs.cgi/ant/antlibs/antunit/trunk'
svn: PROPFIND of '/viewcvs.cgi/ant/antlibs/antunit/trunk': 301 Moved 
Permanently (http://svn.apache.org)

I'm looking into the snapshots, hopefully that'll get me what I need, though 
I'd really like to resolve the svn issue since it seems that most open source 
projects are moving to svn.

On Tuesday 24 January 2006 9:59 am, Nicolas Vervelle wrote:
> Clifton Craig wrote:
> >Stefan,
> >
> >That sounds like exactly what I'm looking for. Only there's one big
> > problem. I'm behind an authenticating HTTP proxy and I can't seem to get
> > my svn client to get through it. Our in office proxy has traditionally
> > caused me such problems and I faced this about a month ago when I was
> > trying to retrieve the FOP trunk. I somehow got it to work then but I'm
> > not sure how. I've never used svn before (asides from my clumsily
> > fumbling and actually getting the FOP trunk). I read somewhere that
> > certain proxies don't handle the extended web-dav commands well or pass
> > them through the way they should. I'm not sure if that's my problem or
> > not. I also read that one solution involved either switching from http to
> > https (or the other way around, I'm not sure). Could you or someone
> > knowledgeable help me get my svn client to retrueve the Ant trunk so I
> > can play with Antunit? Thanx!
>
> There are nightly snapshots available for download:
> http://cvs.apache.org/snapshots/ant/
> So you can get the source code without using svn.
>
> Other idea: maybe there's the possibility to have a web access (html) to
> the repository and a client that can get files from the web access.
> It exists for CVS but I don't know for svn.
>
> Hope this helps
> Nico
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> For additional commands, e-mail: user-help@ant.apache.org

-- 
------------------------------------------------- 
Clifton C. Craig, Software Engineer
Intelligent Computer Systems -  A Division of GBG
ccc@icsaward.com
ccraig@gbg.com

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


Re: Unit test a build

Posted by Nicolas Vervelle <ni...@steria.com>.

Clifton Craig wrote:

>Stefan,
>
>That sounds like exactly what I'm looking for. Only there's one big problem. 
>I'm behind an authenticating HTTP proxy and I can't seem to get my svn client 
>to get through it. Our in office proxy has traditionally caused me such 
>problems and I faced this about a month ago when I was trying to retrieve the 
>FOP trunk. I somehow got it to work then but I'm not sure how. I've never 
>used svn before (asides from my clumsily fumbling and actually getting the 
>FOP trunk). I read somewhere that certain proxies don't handle the extended 
>web-dav commands well or pass them through the way they should. I'm not sure 
>if that's my problem or not. I also read that one solution involved either 
>switching from http to https (or the other way around, I'm not sure). Could 
>you or someone knowledgeable help me get my svn client to retrueve the Ant 
>trunk so I can play with Antunit? Thanx!
>
There are nightly snapshots available for download:
http://cvs.apache.org/snapshots/ant/
So you can get the source code without using svn.

Other idea: maybe there's the possibility to have a web access (html) to 
the repository and a client that can get files from the web access.
It exists for CVS but I don't know for svn.

Hope this helps
Nico


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


Re: Unit test a build

Posted by Clifton Craig <cc...@gbg.com>.
Stefan,

That sounds like exactly what I'm looking for. Only there's one big problem. 
I'm behind an authenticating HTTP proxy and I can't seem to get my svn client 
to get through it. Our in office proxy has traditionally caused me such 
problems and I faced this about a month ago when I was trying to retrieve the 
FOP trunk. I somehow got it to work then but I'm not sure how. I've never 
used svn before (asides from my clumsily fumbling and actually getting the 
FOP trunk). I read somewhere that certain proxies don't handle the extended 
web-dav commands well or pass them through the way they should. I'm not sure 
if that's my problem or not. I also read that one solution involved either 
switching from http to https (or the other way around, I'm not sure). Could 
you or someone knowledgeable help me get my svn client to retrueve the Ant 
trunk so I can play with Antunit? Thanx!

--------------------------------------------------- 
Clifton C. Craig, Software Engineer
Intelligent Computer Systems -  A Division of GBG
ccc@icsaward.com
ccraig@gbg.com

On Monday 23 January 2006 11:58 pm, Stefan Bodewig wrote:
> On Mon, 23 Jan 2006, Ninju Bohra <ni...@yahoo.com> wrote:
> > I too created test cases for my build files (actually they are build
> > files for testing my custom tasks, but they are still build files).
> >
> > I used the BuildFileTest class as the base class (that my JUnit
> > classes extended from).
>
> This is the traditional way Ant used itself, but this is going to be
> replaced by AntUnit step by step.  The difference is that you don't
> write a Java class at all.
>
> Say I want to test the <touch> task and validate it creates a file, I
> write a build file:
>
> <project xmlns:au="antlib:org.apache.ant.antunit">
>   <property name="foo" value="foo"/>
>
>   <target name="tearDown">
>     <delete file="${foo}" quiet="true"/>
>   </target>
>
>   <target name="testTouchCreatesFile">
>     <au:assertFileDoesntExist name="${foo}"/>
>     <touch file="${foo}"/>
>     <au:assertFileExists name="${foo}"/>
>   </target>
> </project>
>
> > The class provided some convience methods for reading the build.xml,
> > initializing the project, and accessing property and log output
> > (very useful when verified build behavior).
>
> AntUnit provides a generic <assert> task (with a nested condition) as
> well as a bunch of macrodef'ed asserts and
>
> > but I never quite thought of "testing" a build script with unit
> > tests (it seems a bit recursive as you would need a build script to
> > invoke the build you are testing...)
>
> an <antunit> task to do just that.  The task takes a bunch of build
> files and runs the targets whose names start with "test", with special
> handling for targets names setUp and tearDown.  And it provides for
> test listeners.
>
> Stefan
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> For additional commands, e-mail: user-help@ant.apache.org

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


Re: Unit test a build

Posted by Stefan Bodewig <bo...@apache.org>.
On Mon, 23 Jan 2006, Ninju Bohra <ni...@yahoo.com> wrote:

> I too created test cases for my build files (actually they are build
> files for testing my custom tasks, but they are still build files).
>  
> I used the BuildFileTest class as the base class (that my JUnit
> classes extended from).

This is the traditional way Ant used itself, but this is going to be
replaced by AntUnit step by step.  The difference is that you don't
write a Java class at all.

Say I want to test the <touch> task and validate it creates a file, I
write a build file:

<project xmlns:au="antlib:org.apache.ant.antunit">
  <property name="foo" value="foo"/>

  <target name="tearDown">
    <delete file="${foo}" quiet="true"/>
  </target>

  <target name="testTouchCreatesFile">
    <au:assertFileDoesntExist name="${foo}"/>
    <touch file="${foo}"/>
    <au:assertFileExists name="${foo}"/>
  </target>
</project>

> The class provided some convience methods for reading the build.xml,
> initializing the project, and accessing property and log output
> (very useful when verified build behavior).

AntUnit provides a generic <assert> task (with a nested condition) as
well as a bunch of macrodef'ed asserts and

> but I never quite thought of "testing" a build script with unit
> tests (it seems a bit recursive as you would need a build script to
> invoke the build you are testing...)

an <antunit> task to do just that.  The task takes a bunch of build
files and runs the targets whose names start with "test", with special
handling for targets names setUp and tearDown.  And it provides for
test listeners.

Stefan

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


Re: Unit test a build

Posted by Ninju Bohra <ni...@yahoo.com>.
I too created test cases for my build files (actually they are build files for testing my custom tasks, but they are still build files).
 
I used the BuildFileTest class as the base class (that my JUnit classes extended from).  The class provided some convience methods for reading the build.xml, initializing the project, and accessing property and log output (very useful when verified build behavior).
 
The class is in the ant-testutil.jar and I have been successfully using with my ANT 1.6.2 install (not sure about anything newer).
 
I would highly encourge the using of build scripts for the testing of custom tasks...but I never quite thought of "testing" a build script with unit tests (it seems a bit recursive as you would need a build script to invoke the build you are testing...)
 
Good luck,
 
Ninju
 


----- Original Message ----
From: Stefan Bodewig <bo...@apache.org>
To: user@ant.apache.org
Sent: Monday, January 23, 2006 3:06:35 PM
Subject: Re: Unit test a build


On Mon, 23 Jan 2006, Clifton Craig <cc...@gbg.com> wrote:

> Great idea. However, I'm a little lost. I have a source distribution
> of Ant-1.6.5

AntUnit is not part of Ant's source distribution, but a subproject on
its own right.  Check out
<http://svn.apache.org/repos/asf/ant/antlibs/antunit/trunk/>, there
even are docs 8-)

It is quite likely that it won't compile against Ant 1.6.5 since its
main developers so far haven't taken the time to even try anything
else but Ant's svn trunk version.  Anyway, give it a try.

Stefan

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

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


Re: Unit test a build

Posted by Stefan Bodewig <bo...@apache.org>.
On Mon, 23 Jan 2006, Clifton Craig <cc...@gbg.com> wrote:

> Great idea. However, I'm a little lost. I have a source distribution
> of Ant-1.6.5

AntUnit is not part of Ant's source distribution, but a subproject on
its own right.  Check out
<http://svn.apache.org/repos/asf/ant/antlibs/antunit/trunk/>, there
even are docs 8-)

It is quite likely that it won't compile against Ant 1.6.5 since its
main developers so far haven't taken the time to even try anything
else but Ant's svn trunk version.  Anyway, give it a try.
 
Stefan

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


Re: Unit test a build

Posted by Steve Loughran <st...@apache.org>.
Clifton Craig wrote:
> On Sunday 22 January 2006 4:55 pm, Steve Loughran wrote:
>> Clifton Craig wrote:
>>> Given my passion for TDD I am now looking for a way to apply unit tests
>>> to my Ant build files. Is there an easy way or framework I can use?
>> you need the antunit test framework; its in Ant's SVN repo. Its really
>> for testing tasks, but comes with a good set of assertions
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
>> For additional commands, e-mail: user-help@ant.apache.org
> Steve,
> 
> Great idea. However, I'm a little lost. I have a source distribution of 
> Ant-1.6.5 that I'm working with and I can't figure out where the antunit test 
> framework begins and where the the actual test cases end.

the antunit sub project creates a library, called something like 
antunit.jar, that contains an antlib with all the test cases and things 
in. If you look through the source for the resource antlib.xml you'll 
find out the tasks it offers, and the URL to use to call it. just add 
the lib to ant's classpath, declare a namespace with the antlib: url and 
use the tasks on demand.

-steve


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


Re: Unit test a build

Posted by Antoine Levy-Lambert <an...@gmx.de>.
Clifton Craig wrote:

>On Sunday 22 January 2006 4:55 pm, Steve Loughran wrote:
>  
>
>>Clifton Craig wrote:
>>    
>>
>>>Given my passion for TDD I am now looking for a way to apply unit tests
>>>to my Ant build files. Is there an easy way or framework I can use?
>>>      
>>>
>>you need the antunit test framework; its in Ant's SVN repo. Its really
>>for testing tasks, but comes with a good set of assertions
>>
>>    
>>
>Steve,
>
>Great idea. However, I'm a little lost. I have a source distribution of 
>Ant-1.6.5 that I'm working with and I can't figure out where the antunit test 
>framework begins and where the the actual test cases end.
>  
>
Hello,

the antunit tests did not exist yet when ant 1.6.5 was released. You
would have to download the source from subversion.

see this web page .
http://ant.apache.org/svn.html

Cheers,

Antoine

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


Re: Unit test a build

Posted by Clifton Craig <cc...@gbg.com>.
On Sunday 22 January 2006 4:55 pm, Steve Loughran wrote:
> Clifton Craig wrote:
> > Given my passion for TDD I am now looking for a way to apply unit tests
> > to my Ant build files. Is there an easy way or framework I can use?
>
> you need the antunit test framework; its in Ant's SVN repo. Its really
> for testing tasks, but comes with a good set of assertions
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> For additional commands, e-mail: user-help@ant.apache.org
Steve,

Great idea. However, I'm a little lost. I have a source distribution of 
Ant-1.6.5 that I'm working with and I can't figure out where the antunit test 
framework begins and where the the actual test cases end.
--------------------------------------------------- 
Clifton C. Craig, Software Engineer
Intelligent Computer Systems -  A Division of GBG
ccc@icsaward.com
ccraig@gbg.com

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


Re: Unit test a build

Posted by Steve Loughran <st...@apache.org>.
Clifton Craig wrote:
> Given my passion for TDD I am now looking for a way to apply unit tests to my 
> Ant build files. Is there an easy way or framework I can use?

you need the antunit test framework; its in Ant's SVN repo. Its really 
for testing tasks, but comes with a good set of assertions

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