Clover can be used with NetBeans 6.1 by integrating Clover for Ant into your NetBeans project build, which is Ant-based. This integration will allow seamless instrumentation, test execution and hard-copy coverage report generation from within NetBeans.
To start, download Clover for Ant at http://www.atlassian.com/software/clover/CloverDownloadCenter.jspa. Once you've downloaded Clover for Ant, expand it to a separate folder (referred to as CLOVER_HOME
). You'll also need a valid Clover license file, which you can obtain at http://www.atlassian.com/software/clover/.
1.1 Go to Preferences->Miscellaneous->Ant and use Add JAR/ZIP to add CLOVER_HOME/lib/clover.jar
to the classpath, you can also add clover.license
(or you can specify this in project's build.xml)
2.1 Open Tools/Libraries
2.2 Click "New Library..." and name it "Clover"
2.3 Add CLOVER_HOME/lib/clover.jar
to the new library.
CLOVER_HOME/lib/clover.jar
to the project classpaths3.1 Open Project/Properties...
3.2 In Libraries add the Clover library to the Compile, Run, Compile tests, Run tests classpaths
4.1 Add the following to the project build.xml
(go to Files view and edit this file)
<target name="-pre-init" depends="with.clover"/> <target name="-post-clean" depends="clover.clean"/> <property name="clover.enable" value="on"/> <property name="clover.reportdir" value="clover_html"/> <!-- You can also specify license here <property name="clover.license.path" value="path/to/clover.license"/> --> <taskdef resource="cloverlib.xml"/> <target name="with.clover" if="clover.enable"> <clover-setup/> </target> <target name="clover.report" depends="-pre-init"> <clover-report> <current outfile="${clover.reportdir}"> <format type="html"/> </current> </clover-report> </target> <target name="clover.clean"> <clover-clean/> </target>
5.1 Perform a complete clean and rebuild of the project by selecting Build->Clean and Build Main Project...
5.2 Select the project build.xml
and run the test
target using the Ant Targets window
5.3 Run the clover.report
target to generate a Clover HTML report
5.4 The clover.enable
can be used to disable Clover integration
5.5 The clover.reportdir
can be used to control where the HTML report is generated
Because NetBeans uses a standard Ant-based build, you can use all of Clover's Ant tasks from your project build file. This allows you to control includes and excludes, set up source-level filters, change report formats and more. For an overview of the Clover Ant tasks, see http://confluence.atlassian.com/display/CLOVER/6.+Ant+Task+Reference