Getting started with DCover CLI

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

1. Download DCover CLI

Please contact Diffblue to obtain DCover CLI.

2. Prerequisites

  • Java 8 or 11 compatible source code (but please note that Java 11.0.7 is NOT supported)
  • Maven projects, version 3.2.5 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.

For Spring projects, either:

  • Use the spring-boot-starter-test dependency  to add Hamcrest
  • Add org.hamcrest:hamcrest. The version of Hamcrest needs to match the relevant version of spring-boot-test. For example, if the user has spring-boot-test:2.4.6, they should look at the dependency list: Maven Repository: org.springframework.boot » spring-boot-starter-test » 2.4.6. This shows that the matching version is Hamcrest 2.2 (you may have to scroll). 
Dependency When Version
JUnit (junit:junit or org.junit.jupiter:junit-jupiter-engine) Unless using Spring or Spring Boot 4.7+
JUnit Launcher (org.junit.platform:junit-platform-launcher) When using junit-jupiter-engine, unless using Maven, Spring or Spring Boot 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 4.2.5+, matching version
Mockito (org.mockito:mockito-core) When using the --mock option 1.9.5+

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 ( 4.2.1+, matching version
Spring Web MVC (org.springframework:spring-webmvc) 5+, matching version

3. Installing DCover 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 DCover 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 DCover 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. Compiling 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.