3

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

These build scripts becomes sometimes large and does a lot of things and basically is source code it self.

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 code coverage tool for Ant build scripts?

pablaasmo
  • 576
  • 7
  • 18

3 Answers3

2

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

pablaasmo
  • 576
  • 7
  • 18
0

We use Cobertura. It works fine and even has coverage for branches.

See http://cobertura.sourceforge.net/

smholloway
  • 589
  • 7
  • 14
AlexWien
  • 28,470
  • 6
  • 53
  • 83
0

I suggest looking at Sonar for unit test and code coverage reporting. It will also run standard Java code analysis tools like Findbugs, Checkstyle and PMD.

Apologies, but the only Stackoverflow example I have (enabling a build for code coverage and unit test reporting) uses cobertura. A more modern tool to use would be jacoco.

For more guidance you are advised to read the Sonar docs.

Community
  • 1
  • 1
Mark O'Connor
  • 76,015
  • 10
  • 139
  • 185
  • I am not thinking of running xunit test from the build script to test other code. I want to test the build script itself and do a code coverage of these tests. – pablaasmo Nov 25 '12 at 10:11
  • @pablaasmo But.... The normal method of creating coverage reports, is to run the unit tests. Sonar now supports additional coverage reports based on integration tests. I understand a reluctance to include additional tools. Personally I would highly recommend Sonar, you'll never look back. – Mark O'Connor Nov 25 '12 at 15:18
  • I know about Sonar, but have not used it. I will have another look at it an see if it meets my needs. Thanks for you answer. – pablaasmo Nov 25 '12 at 21:27