3

In our development environment We have more and more build scripts for ant to perform the build tasks for several different build jobs.

These build scripts sometimes become large and do a lot of things and basically is source code in and of itself.

So in a "TDD-world" we should have unit tests and coverage reports for the source code.

I found AntUnit and BuildFileTest.java for doing unit tests. But it would also be interesting to know the code coverage of those unit tests.

I have been searching google, but have not found anything. Does anyone know of a code coverage tool for Ant build scripts?

Martijn Pieters
14.7k10 gold badges60 silver badges59 bronze badges
asked Nov 28, 2012 at 8:37

2 Answers 2

2

If you convert your Ant scripts to gant (which has a lot of other advantages), then getting coverage would be trivial.

Gant is a tool for scripting Ant tasks using Groovy instead of XML to specify the logic. A Gant specification is a Groovy script and so can bring all the power of Groovy to bear directly, something not possible with Ant scripts. Whilst it might be seen as a competitor to Ant, Gant uses Ant tasks for many of the actions, so Gant is really an alternative way of doing things using Ant, but using a programming language rather than XML to specify the rules...

gnat
20.5k29 gold badges117 silver badges308 bronze badges
answered Nov 28, 2012 at 9:14
1
  • Thanks for your answer. I was not planning to use Groovy, but I will have a look at it. Commented Dec 3, 2012 at 13:03
1

To answer my own question :-)

I have ended up using AntUnit to do unit testing of Ant Build scripts. To to coverage I did not find a tool/library that works out of the box. What I did find that might be usable with some adjustments is Antro (https://sourceforge.net/projects/antro/) with its code at https://github.com/jkff/antro.

Antro is "Ant profiler: a line-level profiler for Ant build scripts"

It uses a listener to collect data about the build script run.

The challenge is to try to use Antunit and Antro together or make a listner for Antunit that can do the same as Antro to collect data.

But then again that might my an interesting challenge to do :-)

answered Feb 14, 2013 at 14:10

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.