The Datarush project is built with Maven 2 and integrated with Hudson. Maven is a tool used for building and managing any Java-based project. Hudson provides automated, continuous build integration system, making it easier for developers to integrate changes to the project.
We need a good code coverage tool for the Datarush project. Code coverage is a measure used in software testing. It is a form of white box testing. Basic code coverage criteria include function coverage, statement coverage, branch coverage, condition coverage, etc.
EMMA is a free good java code coverage tool, but there is no Maven 2 plugin for EMMA now. EMMA’s current edition was publish in 2006 and hasn’t been developed for several years.
Sonar is another good code coverage tool. It requires a relational database for storage of measures data, but not able to keep report history. Sonar’s technical architecture includes cobertura , so it generates similar coverage reports as cobertura tool. The sonar web server requires large RAM to run efficiently.
We chose Cobertura as code coverage tool for our Datarush project. Cobertura is a free Java code coverage tool that calculates the percentage of code accessed by tests. It can be used to identify which parts of your Java program are lacking test coverage. Its coverage metric shows the code coverage percentage of packages, files, classes, methods, lines, and conditionals. Cobertura is based on jcoverage.
Cobertura can be used from Maven 2. Cobertura Maven Plugin provides the features of Cobertura within the Maven environment.
Example of basic configuration:
<project>
. . .
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>cobertura-maven-plugin</artifactId>
<version>2.3</version>
<configuration>
<formats>
<format>html</format>
<format>xml</format>
</formats>
</configuration>
</plugin>
</plugins>
</build>
</project>
The report generated by this plugin is the result of executing the Cobertura tool against your compiled classes, and can be used to identify which parts of your java program are lacking test coverage.
Cobertura can be integrated with Hudson for building/testing software projects continuously.
Here is a sample cobertura code coverage report from Hudson:
