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?
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…
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 🙂