This is the documentation for Clover 3.3. View this page for the

Unknown macro: {spacejump}

of Clover, or visit the latest Clover documentation.

Configuration Options

Compilation Options

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

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.

Instrumentation
  • Includes / Excludes

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

 

  • Instrument test source folders ... - when selected, sources from test folders will be instrumented and treated as test code
  • Instrument lambda functions: whether Java 8 lambda functions shall be instrumented. If instrumented, they're treated like normal methods (and can be shown in HTML report and considered in code metrics, for example). Possible values:
    • none - do not instrument lambda functions,
    • expression - instrument lambdas in expression-like form, e.g. "(a, b) -> a + b",
    • block - instrument lambdas in code blocks, e.g. "(a, b) -> { return a + b; }"
    • all - instrument all lambda functions.

    (warning) Due to Clover's restrictions related with code instrumentation and javac compiler's type inference capabilities, you may get compilation errors when expression-like lambda functions are passed to generic methods or types. In such case disable instrumentation of expression-like form (i.e. use the none or block setting). See the Java 8 code instrumented by Clover fails to compile Knowledge Base article for more details.

Rebuild Policy

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.

  • Ask: The plugin will show a dialog window asking for confirmation.
  • Rebuild Immediately: The plugin will rebuild the project automatically, without asking the user.
  • Never Rebuild Automatically: The plugin will neither rebuild nor display a dialog — with this setting the user is responsible for rebuilding the project manually.

View Options

The second Tab on the configuration panel provides view options;

Screenshot: Clover for IDEA View Options

Refresh Policy

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:

  • project open,
  • finished compilation,
  • termination of unit test or application run.

"Periodically" means that the Clover Plugin will periodically check for new coverage data for you.

General

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.

Span

See Using Spans.

Per-test Coverage Data

Per-test coverage can be disabled to boost performance. If you disable this feature, the following information will not be available:

  • Test results.
  • Code has been uniquely covered by specific tests.
  • Code has been covered by failed tests only.

However, the coverage data will load load faster as a result.

Source Highlighting

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.

Filter Options

The third Tab on the configuration panel provides filter options;

Screenshot: Clover for IDEA Filter Options

Built-in Context Filters

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.

Custom Contexts

This allow you to define custom contexts to ignore when viewing coverage information.

Working with regexp filters:

  • Use or  to Create, Delete or Copy respectively the selected filter.
  • All new and edited regexp filters will be shown in 'blue', indicating that they are currently unavailable.
  • To make a new/edited filter active, you need to delete the existing coverage database using the button and rebuild your project/module.

 

See Coverage Contexts for more information.

 

Example: Creating a regexp context filter

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?

  • Open the configuration panel "Settings | Clover | Filters".
  • Select  to create a new Regexp Context Filter.
  • Set the name to private.
  • Since we are creating this filter to filter private 'methods', specify the Method type.
  • We now need to define regular expression that will match all private method signatures. That is, a regexp that will match any method with the private modifier. An example of such a regexp is (.* )?private .*. Enter this regexp in the regexp field.
  • You will notice that the name of this new filter appears in blue. Blue is used to indicate that the filter is either new or recently edited and therefore 'unavailable'. To make this new filter available, select  from the Main Toolbar and recompile your project. Once active, you will notice the private filter appear in the Context Filter Dialog. You will now be able to filter private methods out of your Clover coverage calculations and reports.

 


Now you have tweaked and hacked Clover according to your developer needs. But you would like to share information about code coverage with you colleagues or present it to management? If yes, read next chapter: 6. Generating reports in IDEA.

 

  • No labels