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

Clover IDEA 3 Plugin UserGuide

Plugin Version 0.8 Beta

Note
The Clover IDEA 3 Plugin is currently a beta version. The plugin has been tested with IntelliJ IDEA versions 3.0.x.

Overview

The Clover IDEA Plugin allows you to instrument your Java code easily from within the IntelliJ IDEA 3.x Java IDE, and then view your coverage results inside IDEA.

Clover IDEA plugin

Installing the plugin

To install the plugin:

  1. shutdown any running instances of IDEA
  2. remove any previous versions of the the clover plugin jar from IDEA_HOME/plugins.
  3. copy CLOVER_HOME/lib/cloverIdeaPlugin.jar into the IDEA_HOME/plugins directory, and restart IDEA.

Using the plugin

Enabling the Clover Plugin for your project

Add cloverIdeaPlugin.jar to your project classpath:

  • Open the project properties "File | Project Properties".
  • In the "Paths" section, select the "Classpath" tab. Remove any old clover jars and add a reference to cloverIdeaPlugin.jar (you must reference the cloverIdeaPlugin.jar that you installed in IDEA_HOME/plugins).

    (The cloverIdeaPlugin.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)

Building your Project with Clover

Clover works by pre-processing your Java files before they are compiled. This means that when you want to measure coverage with Clover, you cannot use the standard IDEA "Rebuild Project" or "Make Project" functionality. Instead, you need to use either "Clover | Rebuild Project with Clover" (for a full rebuild), or "Clover | Make Project with Clover" (builds only modified files). The "Make Project with Clover" action can also be launched with the toolbar button Clover Compile Button.

Note
Clover collects code coverage by instrumenting a copy of your Java files before they are compiled. If you "Build with Clover", then re-compile some of your files normally with IDEA, those files will no longer be instrumented; and coverage will not be collected for them until you do another "Build with Clover".
Build Options

build dialog

Show Compiler Console

Check this box to see output from the Clover build process.

Delete existing Coverage Data

(option only appears on a full rebuild) This option allows you to delete existing coverage data and registry information before the build.

Show this dialog in future

Uncheck this box if you don't want this dialog appearing for future builds. You can enable the dialog again via the Clover Project Properties screen.

Viewing Coverage Results

Once you have instrumented your code (see Building your Project with Clover), each time you run your application or a unit-test Clover will record the code coverage. Once the application or unit-test exits, the coverage information is available for viewing using IDEA.

The coverage information can be browsed using the Clover Tool Window. This presents the data in a similar way to the existing Clover GUI Viewer.

The top pane of the Tool Window contains a class browser with inline coverage information: Clover class browser

The tool bar at the top of the browser contains the following buttons

  • Flatten Packages. With this selected, only concrete packages are shown in the browser.
  • Autoscroll to Source. With this selected, a single click on a class in the browser will load the corresponding source file in an editor pane, with coverage info overlaid.
  • Refresh. Reloads coverage data.
  • Expand All. Expand all nodes in the browser.
  • Collapse All. Collapse all nodes in the browser.
  • Set Context Filter. Launches a dialog to set the context filter: Context Filter Dialog

The bottom pane of the Tool Window contains Coverage and other Metrics information for the currently selected node in the browser: Coverage info view

In addition, the plugin can annotate the Java code with the coverage information. This can be turned on using the "Clover | Show Coverage" menu option, or by pressing the Show Coverage view coverage button toolbar button. editor pane with overlaid coverage information

Note
If you do not have "Auto Coverage Refresh" enabled, you will need to press the Refresh Button in the Clover Tool Window to see the updated coverage information.

If a source file has changed since a Clover build, then a warning will be displayed alerting you to fact that the inline coverage information may not be accurate. The coverage hilighting will be yellow, rather than the red shown above.

Configuration Options

Configuration options for Clover are accessible on the Clover panel of the Project Properties dialog.

Compilation options

Compiler configuration screen

Initstring

This section controls where the Clover coverage database will be stored. Select 'Automatic' to have Clover manage this location for you (relative to your project directory). Select 'User Specified' to 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.

Compilation with Clover

These settings control how the Java compiler operates when building your project with Clover.

Filtering

Allows you to specify a comma separated list of set of Ant Patternsets that describe which files to include and exclude in instrumentation. These options are the same as those described in the <clover-setup> task.

Viewer options

Viewer configuration screen

General

Controls the operation of the Clover tool window on the left-hand side of the IDE.

Context Filters

Allows you to specify contexts to ignore when viewing coverage information.

Source Highlighting

Allows you to specify colors used when displaying source level coverage information.