Links

Using Cover CLI in Eclipse

How to install and run Diffblue Cover CLI as an external tool in Eclipse.
Please see this YouTube video for a walkthrough of using Cover as an external tool in Eclipse. The video covers setup and test creation.

1. Download Diffblue Cover CLI

Please contact Diffblue to obtain a copy of the Diffblue Cover CLI.

2. Prerequisites

Please ensure all of the prerequisites for using Diffblue Cover have been met.

3. Installing Diffblue Cover CLI

Download the zip file from Diffblue and unzip in a suitable location:(installation_location)
  • dcover.bat - a batch script (Windows)
  • dcover - a bash script (Linux/macOS).

4. Configuring Diffblue Cover CLI

  1. 1.
    Go to Run > External Tools > External Tools Configuration… and enter a Name for the new configuration (e.g. Cover).
  2. 2.
    Enter or browse to select the Location of the Cover executable.
  3. 3.
    Enter or browse to select the Working Directory for the location of your project.
  4. 4.
    Enter the following command:
create ${java_type_name} --class-name-template=$"{CLASS_NAME}Tests"
--merge --skip-intermediate-test-verification
--skip-test-validation --batch
create
The create command for Cover.
${java_type_name}
The class you wish to run Cover on. This is a variable that eclipse replaces with the selected class when run.
--class-name-template=$"{CLASS_NAME}Tests"
This will change the class names so that the classes have the same names as the existing ones (provided that the existing test classes use a standard naming convention). The quotes around {CLASS_NAME} are required so that Eclipse does not interpret this as one of its own variables.
--merge
This merges these tests with your existing classes (instead of replacing them).
--skip-intermediate-test-verification
Generates more potential tests, and saves time by not verifying them.
--skip-test-validation
Generates more potential tests, and saves time by not validating them.
--batch
To make the output cleaner.
5. Select the option Refresh resources upon completion so that you see the new tests in your IDE once Cover has run.

5. Running Diffblue Cover CLI

  1. 1.
    Select a Java class and then open it.
  2. 2.
    Then click Run External Tool in the top toolbar.
  3. 3.
    The Cover output is now seen in the console below.