Home | Clover | Clover.NET | FishEye | Support | Account | Download | Buy Now

Clover Netbeans Module

Plugin Version 0.5.1.02

Note
The Clover Netbeans Module is currently a beta version. The module has been tested against Netbeans 3.5

Overview

The Clover Netbeans Module allows you to instrument your Java code easliy from within the Netbeans Java IDE, and immediately view your coverage results within the IDE.

Clover Netbeans Plugin

Installing the Module

Install the Clover Netbeans Module using the Update Center.

  • Open the Update Center Wizard by selecting "Tools | Update Center".
  • Select the "Install manually" option and follow the onscreen instructions (The Clover Netbeans Module is located in the lib/clover-netbeans.nbm file).

Configuring the Module

Add clover-netbeans.jar to your project classpath by mounting the clover-netbeans.jar.

  • Open the mount filesystem wizard "File | Mount Filesystem".
  • Select "Archive Files" and "Next"
  • Select the clover.jar located in either the modules subdirectory of your user directory, OR if the module is installed as 'global', then the modules subdirectory of the NB Installation directory

    (The clover-netbeans.jar needs to be in the classpath because it is needed at runtime when you are running your unit tests. It is also needed when you are compiling with Clover)

Using the Module

Clover instruments your code by pre-processing your Java files prior to compilation. This means that you will need to select "Clover Instrumentation" as your Default Compiler for Java Sources. You can do this by the following steps.

  • Select the "Build with Clover" toggle button Compile with clover button in the Clover Toolbar

    Alternatively, the following option is equivalent.

    • You can modify the Default Compiler through the "Tools | Options" interface. Select "Options | Editing | Java Sources" and select "Clover Instrumentation" as the Default Compiler property.

Now, whenever you Compile or Build your source, it will be instrumented by Clover. This includes the "Project | Build Project" menu item, and the build/compile options available through the context sensitive right-click popup menus.

Build Options

Build with clover button Rebuild Coverage

This option allows you to delete existing coverage data, and rebuild the project using the latest configuration and available source. Use this when the coverage database has become 'out-of-sync' with the project as a result of java sources being deleted, or excludes configurations changing.

Viewing Coverage Results

Once you are instrumenting your code, Clover will gather code coverage information whenever you execute your code. This information can be viewed in the form of a clover coverage browser and annotations of your source file.

Coverage Browser

The top pane of the Clover Coverage Tab contains a class browser with inline coverage information:

Clover class browser

The tool bar at the top of this browser contains the following options:

  • tool bar icon Flatten Packages. With this selected, only concrete packages are shown in the browser.
  • tool bar icon Refresh. Reloads coverage data. This button is disabled when "Auto Refresh" is active.

The bottom pane of the Clover Coverage Tab contains Coverage and other Metrics information for the currently selected node in the browser.

Coverage info view

Inline source annotation

In addition, the plugin can annotate the Java source with the coverage information in the editor pane. This is available whenever the open source file has associated coverage data. The annotations are controlled via a toolbar in the editor pane

editor tool bar. These toolbar buttons allow you to:

  • editor tool bar icon Move to the previous uncovered line
  • editor tool bar icon Toggle display of annotations
  • editor tool bar icon Move to the next uncovered line

editor pane with overlaid coverage information

To ensure that the presented coverage information is up-to-date, either tell Clover to refresh by selecting the "Refresh" button in the Clover Coverage Tab OR configure clover to periodically check for updated coverage information for you.

When the coverage information becomes out of date, the inline source annotations change to yellow.

editor pane with overlaid coverage information

Configuration

You will find Clover Configuration Options within the Netbeans Options Viewer.

  • "Building | Compiler Types | Clover Instrumentation"
  • "IDE Configuration | Server And External Tool Settings | Clover Settings"

Clover Instrumentation

Initstring

This section controls where the Clover coverage database will be stored. If left blank, Clover will manage this location for you (relative to your project directory). Otherwise, you may nominate the path to the Clover coverage database. This is useful if you want to use the plugin in conjunction with an Ant build that already sets the location of the Clover coverage database.

Flush Policy

The Flush Policy controls how Clover writes coverage data to disk at runtime. See Flush Policies.

View Settings

Auto Refresh

The Auto Refresh control allows you to enable/disable Clovers automatic coverage update monitoring. When set to true, Clover will automatically refresh coverage data. The refresh interval can be managed via the "Refresh interval" setting.

Refresh interval

The Refresh interval value, specifies, in milliseconds, the time interval Clover will use when automatically checking for coverage updates. See also Auto Refresh.

Show Summary

The Show Summary control allows you to show/hide the Coverage Summary bar in the Clover Toolbar. This summary bar provides you a graphical indication of your coverage for the entire project.

FAQ

Q: Ive run my tests, but coverage information is not being displayed in the IDE:

A:You will need to either select "Auto Refresh" to true, or select reload reload icon

Q: I only see coverage data for the last test case I executed.:

A: Clover will display the coverage information gathered from your last test run. This means, that if you run each of your tests individually, then only the coverage from the last test executed will be shown. Support for aggregating multiple test runs is supported via spans, to be included in a future release.

Q: I have an existing Ant build script with clover integration. Can I view the coverage information within Netbeans:

A: By setting the "InitString" property on "Clover Instrumentation" to an existing coverage database (one maintained by an Ant build script for example), you can access all of the viewing features supported by the plugin. Just make sure that you have the source files for this coverage data mounted. You can then safely make changes to your source within Netbeans, build and run your tests with Ant, and the view the coverage results with Clover. If you are going to take this approach, it is best to ensure that the "Build with Clover" toggle button Compile with Clover is NOT selected.

Q: My source files will not compile:

A:Ensure that you have the clover-netbeans.jar in your project classpath.

Known Issues

  • Use Class Include/Exclude does not work.
  • It is not expected that future releases will be backward compatible with this release.
  • A problem exists with "Auto Refresh" where it will not refresh coverage data after an IDE restart. The coverage information will need to change before the coverage data will be updated.