Getting started with the Cover CLI tool

A quick guide to writing unit tests for the single-module Maven example project, CoreBanking, using the Cover CLI.

1. Download Cover CLI

Please contact Diffblue to obtain Cover CLI 3.0.

2. Prerequisites

  • Java 8 or 11 compatible source code
  • Maven projects, version 3.6 and above
  • Gradle projects, version 2.6 and above.

Dependencies required for running tests should be in the project configuration. JUnit is always mandatory but other libraries may also be necessary depending on the project under test.

Dependency When Version
JUnit (junit:junit or org.junit.jupiter:junit-jupiter-engine) Always 4.7-5.6
JUnit Launcher (org.junit.platform:junit-platform-launcher or org.apache.maven.plugins:maven-surefire-plugin) Always 1+
Spring Boot Test (org.springframework:spring-boot-test) when using Spring Boot (org.springframework:spring-boot) 2+, matching version
Spring Test (org.springframework:spring-test) when using Spring (org.springframework:spring-core) unless using Spring Boot 5+, matching version
Mockito (org.mockito:mockito-core) when using the --mock option 2.1.0 to 3.3.0

Other dependencies listed below may be needed, if they are transitive dependencies of your project. If one of these dependencies is required but missing, tests will be generated for some classes but not others. A message will appear in the console output indicating a missing dependency.

Dependency Version
Java Servlet API (javax.servlet:javax.servlet-api) 4+, matching version
JSR107 API and SPI (javax.cache:cache-api) 0.2+, matching version
Spring Boot Starter Test (org.springframework.boot:spring-boot-starter-test) 2+, matching version
Spring Security Config ( 5+, matching version
Spring Web MVC (org.springframework:spring-webmvc) 5+, matching version

3. Installing 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).

To be able to run the Cover CLI on multiple projects, add the relevant script to your path, or create an alias.

4. Add Cover CLI to environment search path


Add the following line to your ~/.profile (Linux) or ~/.zprofile (macOS):


You will need to log out and in again, or reload your profile with source ~/.(z)profile for the changes to your path to become active.


Add the Cover CLI installation location to the PATH environment variable:

Control Panel → System and Security → System → Advanced System Settings → Environment Variables

You will need to start a new shell window for the changes to your path to become active.

5. Check you can run DCover

Run dcover --help to confirm that the command is found on your path and to view help information about the tool.

6. Cloning CoreBanking

The CoreBanking application can be found at

git clone

7. Compile the project

Cover analyses both the source and the Java bytecode, thus the application must be compiled:

cd CoreBanking

mvn compile

8. Writing new tests

In order to create a new set of tests with dcover use the create subcommand.

For example, running the following command from the root of the CoreBanking project:

dcover create

will produce tests for all accessible functions within the project. By default, tests will be stored in files called ClassNameDiffblueTest. If these files already exist, by default they will be replaced when the command is invoked again.

If you prefer to save the tests to a location other than src/test/java, use the --test-output-dir or -d option, e.g.:

dcover create --test-output-dir=src/test/diffblue

Note that, for multi-module projects, it is required to be able to compile the individual module and to run the dcover command within the module directory rather than the root of a multi-module project.

9. Next steps

Please checkout the knowledge base for more guides, videos and information.