All Versions
Clover 4.0 DocumentationClover 3.3 Documentation
Clover 3.2 Documentation
More...
This page contains all user documentation for Clover-for-IDEA. Click a heading in the table below to jump to that section.
On this page:
The Clover IDEA Plugin allows you to instrument your Java code easily from within the IntelliJ IDEA Java IDE, and then view your coverage results inside IDEA.
Screenshot: Clover for IDEA Plugin
This getting started guide will take you through the steps required to generate Clover coverage for your project.
Clover will record the code coverage information each time you run your application or a unit-test. This coverage information is available for viewing using IDEA.
The coverage information can be browsed using the Clover Tool Window. The upper portion of the tool window contains a project class browser with inline coverage information:
Screenshot: Clover Coverage Window
The tool bar at the top of the browser contains the following buttons:
The coverage treemap report allows simultaneous comparison of classes and package by complexity and by code coverage. The treemap is divided by package (labelled) and then further divided by class (unlabelled). The size of the package or class indicates its complexity (larger squares indicate great complexity, while smaller squares indicate less complexity). Colours indicate the level of coverage, as follows:
Screenshot: Clover Coverage Treemap Report
The percentage shown in the yellow box is the code coverage for the class currently under the mouse.
View the TreeMap report for current project using the button.
The types of classes you want included in the Clover Coverage View can be set with Context Filters:
Screenshot: Setting Context Filters
The lower portion of the Tool Window contains various Metrics for the currently selected node in the browser:
Screenshot: Clover Tool Window Summary
In addition, the plugin can annotate the Java code with the coverage information. This can be turned on by pressing the Show Coverage toolbar button.
Screenshot: Annotated Java Code
If you do not have "Auto Coverage Refresh" enabled, you will need to press the Refresh Button in the Main Toolbar or 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 highlighting will be yellow, rather than the red shown above.
The Test Run Explorer displays recently run tests in your Clover-instrumented project.
The upper panel displays test cases as a flat list ( ), grouped by package ( ) or by source root folder ( ).
The lower panel displays classes and methods covered by the testcase selected in the upper panel. Two metrics are displayed for each class and method:
Screenshot: Test Run Explorer
It is possible to view currently selected element in Clover using the Alt-F1 menu.
If the cursor is inside a recognized test case, it would be displayed in Test Runs Explorer, listing methods touched by the test in the lower panel.
Otherwise the element under cursor is displayed in the Coverage view.
Configuration options for Clover are accessible on the Clover panel of the Project Properties dialog. The first Tab on this panel provides compilation options:
Screenshot: Clover for IDEA Compilation Options
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.
The Flush Policy controls how Clover writes coverage data to disk at runtime. See Flush Policies.
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. You can also specify whether source in test folders should be also instrumented.
For example, by using an "Excludes" value of _**/remote/*.java _ you will stop instrumentation of files in the "remote" folder of your project.
It is now possible to change exclusion/inclusion patterns directly from the Project Explorer.
Right click on a package or file, click the Change Exclusion context menu and select whether a pattern corresponding to the selected element should be added (or removed) from your includes or excludes list.
Files in the Project Explorer are annotated by gray or green clover when they are currently excluded or included by the current Clover configuration. A package is annotated when it is explicitly excluded or included.
When your Includes/Excludes are edited manually via the settings, the package annotation may not work correctly (manual pattern may be not recognized), but the file annotation always reflects what the Clover instrumenter will use.
Screenshot: Right-Click Context Menu for Setting Includes and Excludes
The Clover database becomes obsolete after certain operations (such as toggling Build with Clover). The Rebuild Policy setting allows defining the plugin's behavior in the case of such an event.
The second Tab on the configuration panel provides view options;
Screenshot: Clover for IDEA View Options
The Refresh Policy controls how the Clover Plugin monitors the Coverage Database for new data.
"Manual" means that you have to click button to refresh the coverage data.
"Automatic" means that the Clover Plugin will refresh the database on:
"Periodically" means that the Clover Plugin will periodically check for new coverage data for you.
Allows you to customize where coverage data is displayed within the IntelliJ IDE. Gutter marks appear in the left hand gutter of the Java Source Editor. Source highlights appear directly over your source code. Shortcut marks appear in the right hand gutter and allow you to navigate directly to uncovered regions of code.
See Using Spans.
Per-test coverage can be disabled to boost performance. If you disable this feature, the following information will not be available:
However, the coverage data will load load faster as a result.
Allows you to fine tune the colours used Clover in its coverage reporting. The 'highlight colour' for each item is used for Source Highlights and the 'stripe colour' for each item is used for Gutter and Shortcut marks.
The third Tab on the configuration panel provides filter options;
Screenshot: Clover for IDEA Filter Options
Allows you to specify contexts to ignore when viewing coverage information. For example, selecting the finally body context will remove 'finally' block bodies ('block' syntatic constructs in the Java language) from the reported coverage. For more information, see Coverage Contexts in the Clover Core documentation.
This allow you to define custom contexts to ignore when viewing coverage information.
Working with regexp filters:
See Coverage Contexts for more information.
For the sake of this example, let us assume that we want to remove all private methods from the coverage reports. How would we go about this?