Getting started with a Diffblue Cover IntelliJ plugin

A quick guide to writing unit tests for a demonstration project, using a Diffblue Cover IntelliJ plugin.

1. About the Cover IntelliJ plugins

There are two Diffblue IntelliJ Plugins - the full Cover IntelliJ plugin and the Cover Community Edition IntelliJ plugin. Cover Community Edition is free and can be used for Open Source projects; the full (paid) version of Cover can be used for any project and comes with full support from Diffblue.

The documentation below and in the knowledge base describes this version, and full support is available.

To get the free Community Edition Cover IntelliJ plugin, please go to the download page. The documentation below and in the knowledge base covers this version but may also contain features which are not available in the Community Edition. Community Support is available from the Community Forum.

2. Prerequisites

  • IntelliJ version 2019.3 or later
  • Java 8 or 11 source code
  • Maven or Gradle-based project
  • 2 GB minimum memory requirement (to amend this in IntelliJ, select Help then Change Memory Settings)
  • Your project must compile and run

Diffblue Cover runs the tests that it writes for your code, so your project must compile and run for Cover to work properly. Your project configuration (e.g., pom.xml for Maven projects) must include all required dependencies, and they must all have been built or downloaded (e.g., by doing mvn clean install for Maven projects). JUnit is always a required dependency.

Dependency When Version
JUnit (junit:junit or org.junit.jupiter:junit-jupiter-engine) Always 4.7-5.7
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

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 Event Log 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

Please note that you can only run one instance of the Cover IntelliJ plugin on a project. Running more than one instance on the same project is NOT supported.

3. Installing Cover IntelliJ Plugin

If you are not installing directly from the JetBrains marketplace, download the zip file to a suitable location.

From the IntelliJ IntelliJ IDEA -> Preferences (macOS) or File -> Settings (Windows/Linux) menu, select the Plugins item.

Click on the cog-wheel icon to the right of the Installed tab at the top of the window. From the drop-down menu, select Install Plugin from Disk...

Navigate to the location of the plugin, select the zip file, and then click Open. Click OK.

When prompted to do so, click to Restart IDE, and then click OK.

4. Importing CoreBanking 

The CoreBanking application is a simple banking application for demo purposes which can be found at

Start IntelliJ without a project loaded to see the welcome screen:

Choose the Get from Version Control option. Select Git from the Version control dropdown box. Enter the CoreBanking url into the repository box, selecting an appropriate location for the project. Then, click Clone.

Once it has been successfully cloned, expand the CoreBanking section under Project to see the source tree.

5. Writing new tests

In order to generate new tests for a class which is not currently covered:

  1. Select the Project window.
  2. Select CoreBanking->src->main->java->io.diffblue.corebanking->account->Account.
  3. Right-click and select the Write Tests option from the menu.

The plugin builds the project before analyzing the code and creating the tests. Once the project has been built, click the progress bar at the bottom of the screen to open a pop-up window.

The progress window will show the different stages that the analysis is going through. While the code is being analyzed, it is possible to view the current progress, but in smaller projects, such as CoreBanking, this is a very short time-frame.

Once the new tests have been created, they will be automatically integrated into the project under src/test/java.

* Note that it is also possible to Write Tests by right-clicking the following:

  • Individual classes from within the source editor
  • Individual methods from within the source editor
  • Individual classes from the tab at the top of the source file
  • Individual methods from within their classes in the Project menu (if Show Members has been selected after right-clicking on the Project menu)

Elsewhere within the IDE, for example in test classes or non-Java files, the Write Tests feature is disabled.

6. Running the tests

After Diffblue Cover has written tests for your project, they will be automatically integrated into your test suite. Tests created by Diffblue Cover make use of the JUnit testing framework so junit is included in the CoreBanking project dependencies in the pom.xml.

In project explorer, select the new class from CoreBanking->src->test->java->io.diffblue.corebanking->AccountTest, then right-click and select Run 'AccountTest'.

This will then show the results of the JUnit run:

7. Next steps

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