OverviewJUnit Quilt was developed to provide a simple method of measuring code coverage for when you execute tests. The way its done today, is through the use of JUnit. It also assumes a familiarity with Ant, as Ant is the prefered way of triggering Quilt. (And my prefered way of running JUnit.) In the future, the number of locations that you can use Quilt is likely to change, as well as the quality of the data that is produced. (i.e. using Quilt in a Servlet Container, EJB Container, within an IDE, etc.) Be sure to let me know about any problems you run into with Quilt, and check back on the SourceForge page frequently to see if there are any changes. Version 0.4The prefered way of running Version 0.4 is through Ant. The definition of the Ant task has changed from previous versions (unreleased, I believe.) Defining the Ant TaskTo define the Ant task for triggering Quilt, you need to do two parts. Define the Quilt Classpath, and actually define the task. <path refid="quilt.classpath"> <pathelement location="${lib.repo}/quilt-0.4.jar" /> <pathelement location="${lib.repo}/bcel-5.0.jar" /> <pathelement location="${lib.repo}/commons-graph-0.8.jar" /> <pathelement location="${lib.repo}/commons-collections-2.0.jar" /> <pathelement location="${lib.repo}/colt-1.0.2.jar" /> </path> <taskdef name="quilt" classname="junit.quilt.ant.AntQuiltRunner" classpathref="quilt.classpath" /> Using the Quilt TaskNow that the Quilt task is defined, you need to actually call it. Here is an example: <quilt reportdir="${reports.dir}" register="junit.quilt.cover.ball94.B94Registry" reporter="junit.quilt.reports.XMLSummary" packages="${package.prefix}"> <classpath> <pathelement location="${build.dir}/classes" /> <pathelement location="${build.dir}/test" /> <fileset dir="${lib.dir}"> <include name="**/*.jar" /> </fileset> </classpath> <fileset dir="${test.src}"> <include name="**/AllTests.java" /> </fileset> </quilt> reportdir is the directory where coverage reports should be output to. registry is the registry class for the instrumentation algorithm to use. The following algorithms are available:
reporter is the report generator to be used. The following reporters are available:
packages is a comma seperated list of package names to instrument. If the class doesn't start with one of these packages, it will not be instrumented, and no data will be available. classpath is the complete classpath required in order to execute the tests. fileset is the collection of either Java or Class files which are the JUnit tests to be executed. |