LogoLogo
diffblue.comFree trial
  • Discover Diffblue Cover
  • Get Started
    • What is Diffblue Cover?
    • Get started
      • Free trial
      • Get started - Cover Plugin
      • Get started - Cover CLI
      • Get started - Cover Pipeline
      • Get started - Cover Reports
    • Specs & Reqs
    • Reference Deployments
    • Licensing
      • Online license activation
      • Offline license activation
      • Diffblue License Manager
    • Update Cover
    • FAQs
    • Diffblue Learning
      • Get started
        • Just the basics
        • Free trial
        • Cover Plugin (IDE)
        • Cover CLI (Command Line)
      • Developer
        • Unit tests (IDE)
        • Unit tests (CLI)
        • Test coverage
      • DevOps
        • GitHub
        • GitLab
        • Other CI
      • Administrator
        • Admin - IntelliJ
        • Admin - CLI
        • Admin - Reports
      • Test coverage
        • Developer
        • Senior developer
        • Cover Reports Administrator
  • EVALUATION & ONBOARDING
    • Proof of Value
    • Jumpstart
      • Prerequisites for onboarding
      • Phase 1: Up and running
        • Module 1: Create your Cover unit test baseline
        • Module 2: Cover Pipeline CI integration
      • Phase 2: Developer productivity
        • Module 3: Getting started using Cover
        • Module 4: Introduction to Cover Reports
      • Phase 3: Advanced topics
        • Module 5: Speed up your test execution
        • Module 6: Getting more from Cover
  • Features
    • Cover Plugin
      • Writing tests
        • Gutter icons
        • Menu options
        • Run configurations
        • Cover Plugin tool window
        • Test Review
        • Test examples
        • Creating partial tests
        • Creating skeleton tests
        • Covering all enum values
        • Test insertion order
        • Diffblue Sandbox
        • Environment Check Cache
      • Project configuration
        • General dependencies
        • Test framework dependencies
      • Cover Plugin settings
        • Test Naming
        • Test Formatting
        • Spring configuration options
        • Method Annotations
        • Test Directory
        • Reset Cover Plugin settings
      • Cover Plugin admin
        • Core Maintenance
        • Cover Plugin toolbar menu
        • Cover Plugin status bar widget
        • Telemetry
        • Memory management
        • Using SonarQube with Cover Plugin
        • Log files
        • Troubleshooting
    • Cover CLI
      • Writing tests
        • Command summary
        • Test examples
        • Creating partial tests
        • Customizing test inputs
        • Customizing test setup
        • Test naming
        • Test formatting
        • Test insertion order
        • Patch files
        • Diffblue Sandbox
        • Operational behaviors
        • Test validation
      • Project configuration
        • Preflight checks
        • General dependencies
        • Test framework dependencies
        • Compiling your project successfully
          • Building a Maven project
          • Building a Gradle project
        • Configuring Cover to work with your project's build system
          • Quick guide
          • Configuration file in detail
          • Getting Started with Ant Projects
          • Default configuration
        • Mocking using Mockito
        • Spring profiles
        • Runtime environment
      • Commands & Arguments
        • Environment configuration for CI
        • Packages, classes, and methods
        • Quoting command line arguments
        • Argument files
      • Cover CLI admin
        • Core Maintenance
        • Telemetry
        • Memory management
        • Using Cover CLI in Eclipse
        • Using SonarQube with Cover CLI
        • Log files
        • Troubleshooting
      • Environment Configuration
    • Cover Pipeline
      • Cover Pipeline for CI
        • Quick Start - General
        • Quick Start - Jenkins
        • Quick Start - Azure Pipelines
        • Quick Start - AWS Codebuild
        • Integrating Diffblue Cover into CI on pull requests
        • Installation - VMs or CI run
      • Cover Pipeline for GitLab
        • Introduction
        • Installation and initial setup
        • GitLab workflow
        • Configuration
        • Troubleshooting
        • Related topics
      • Cover Pipeline for GitHub
        • Introduction
        • Installation and initial setup
        • GitHub workflow
        • Configuration
        • Troubleshooting
        • Related topics
    • Cover Reports
      • Cover Reports Contributor
        • Java project config (JaCoCo)
        • Generate and upload reports bundles
        • Authenticated uploads
      • Cover Reports User
        • Navigation
        • Dashboards
        • Telemetry data
        • Export API
        • Considerations
      • Cover Reports Administrator
        • Install and update Cover Reports
        • Configuration options
        • Database backup
        • SSO with Cover Reports
        • Uninstall Cover Reports
    • Cover Optimize
      • Get started - Cover Optimize
      • Cover Optimize & Gradle
      • Cover Optimize & Maven
      • Patch files
    • Cover Refactor
      • Get started - Cover Refactor
    • Cover Annotations
      • Mocking Annotations
      • Custom Input Annotations
      • Interesting Value Annotations
    • Output Codes
      • E - Environment Codes
      • L - License Codes
      • R - Reason Codes
      • T - Testability Codes
      • V - Validation Codes
      • Working with output codes
        • Working with code E020
        • Working with codes E057 to E065
        • Working with code E085
        • Working with code R005
        • Working with code R006
        • Working with code R008
        • Working with code R011
        • Working with code R012
        • Working with code R013
        • Working with code R026
        • Working with code R031
        • Working with code V003
    • Tutorials
      • How to measure test quality
      • How to improve code coverage
      • How to test a new feature
      • How to find regressions
      • How to use Diffblue Cover in test driven development (TDD)
      • How to write tests for Kotlin projects
      • Examples of tests created by Diffblue Cover
      • Best practices for testing private methods
  • Updates & Upgrades
    • Update Cover
    • Cover Editions
    • What's new
    • Release archive
      • 2025-05-01
      • 2025-04-02
      • 2025-04-01
      • 2025-03-02
      • 2025-03-01
      • 2025-02-02
      • 2025-02-01
      • 2025-01-02
      • 2025-01-01
      • 2024-12-02
      • 2024-12-01
      • 2024-11-02
      • 2024-11-01
      • 2024-10-02
      • 2024-10-01
      • 2024-09-02
      • 2024-09-01
      • 2024-08-02
      • 2024-08-01
      • 2024-07-04
      • 2024-07-03
      • 2024-07-01
      • 2024-06-02
      • 2024-06-01
      • 2024-05-02
      • 2024-05-01
      • 2024-04-02
      • 2024-04-01
      • 2024-03-02
      • 2024-03-01
      • 2024-02-02
      • 2024-02-01
      • 2024-01-02
      • 2024-01-01
      • 2023-12-02
      • 2023-12-01
      • 2023-11-03
      • 2023-11-02
      • 2023-11-01
      • 2023-10-02
      • 2023-10-01
      • 2023-09-02
      • 2023-09-01
      • 2023-08-02
      • 2023-08-01
      • 2023-07-03
      • 2023-07-02
      • 2023-07-01
      • 2023-06-02
      • 2023-06-01
      • 2023-05-02
      • 2023-05-01
      • 2023-04-02
      • 2023-04-01
      • 2023-03-02
      • 2023-03-01
      • 2023-02-02
      • 2023-02-01
      • 2023-01-02
      • 2023-01-01
      • 2022-12-02
      • 2022-12-01
      • 2022-11-02
      • 2022-11-01
      • 2022-10-03
      • 2022-10-02
      • 2022-10-01
      • 2022-09-02
      • 2022-09-01
      • 2022-08-05
      • 2022-08-03
      • 2022-08-02
      • 2022-08-01
      • 2022-07-02
      • 2022-07-01
      • 2022-06-02
      • 2022-06-01
      • 2022-05-02
      • 2022-05-01
      • 2022-04-02
      • 2022-04-01
      • 2022-03-02
      • 2022-03-01
      • 2022-02-02
      • 2022-02-01
      • 2022-01-02
      • 2022-01-01
      • 2021-06-02
      • 2021-02-01
  • Legal
    • Diffblue Legal
      • Diffblue End User License Agreement (EULA)
      • Cover Third Party Notices and/or Licenses
      • Privacy Notice
Powered by GitBook
On this page
  • eLearning
  • 1. Install Diffblue Cover Plugin for IntelliJ
  • 2. Apply a license
  • 3. Try it out
  • Step 1 - Clone the example project Spring PetClinic
  • Step 2 - Compile the project and check your environment
  • Step 3 - A couple of basics
  • Step 4 - Automatically write tests for the example project
  • More...
  • What does the plugin do?
  • More tests
  • Next steps
  • Diffblue Cover - one AI

Was this helpful?

Export as PDF
  1. Get Started
  2. Get started

Get started - Cover Plugin

PreviousFree trialNextGet started - Cover CLI

Last updated 1 month ago

Was this helpful?

Get started with Diffblue Cover Plugin for IntelliJ - in short, install the plugin, apply your license, and you're ready to go. This topic also provides an example and some next steps.

If you've already done this as part of your free trial, you may want to skip this and jump straight to the Cover Plugin details, or perhaps you want to update to the latest version - see Update Cover.

eLearning

Short on time? If you'd like a fast-track experience check out our getting started video. [5 min]

1. Install Diffblue Cover Plugin for IntelliJ

  1. In the IntelliJ IDE, open the Plugins menu - either File > Settings > Plugins (Windows/Linux) or IntelliJ IDEA > Preferences > Plugins (macOS).

  2. Select the Marketplace tab, search for Diffblue, and click Install. Your plugin will now be downloaded and installed.

  3. When prompted, click Restart IDE to complete the install.

  1. In the IntelliJ IDE, open the Plugins menu - either File > Settings > Plugins (Windows/Linux) or IntelliJ IDEA > Preferences > Plugins (macOS).

  2. Click on the cog icon next to the Installed tab and select Install Plugin from Disk.... Navigate to the location of the plugin, select the zip file, and click OK.

  3. When prompted, click Restart IDE to complete the install.

2. Apply a license

Once IntelliJ has restarted, you'll be prompted for your license key (provided in your welcome email or by your organization) to activate the plugin. Alternatively, the license can be activated at any time from the IntelliJ toolbar Diffblue > Activate License. Diffblue Cover requires a remote license check with the Diffblue licensing server each time it's used. For help troubleshooting license keys, network connections, and proxy server settings, see Licensing. Note that:

  • Applying a license provides access to the Teams and Enterprise Editions of Diffblue Cover.

  • Cover Plugin Community Edition is free to use but does require product verification to activate your perpetual license.

  • Offline license activation is available with the Diffblue Cover Enterprise Edition only. This can only be done through the CLI.

  • See Cover Editions and Licensing for more details.

3. Try it out

Four steps to automatically write tests - clone an example project, compile the project and check your environment, learn a few basics, and then one click or one command to write tests.

Step 1 - Clone the example project Spring PetClinic

We're going to make use of an example project (Spring PetClinic) to show the Diffblue Cover Plugin for IntelliJ at work. First, we'll clone the project from the Git repo:

  1. Open a command line and navigate to where you want to clone this project.

  2. Run the following commands:

git clone https://github.com/diffblue/demo-spring-petclinic
  1. Open the PetClinic project in IntelliJ.

From IntelliJ select File > New... > Project from version control.

  • Ensure Git is selected in Version control.

  • Enter https://github.com/diffblue/demo-spring-petclinic as the URL.

  • Select the directory/folder to clone the project to.

  • When you're ready, click Clone.

Step 2 - Compile the project and check your environment

Before we write any tests, we need to compile the PetClinic project. Diffblue Cover works by analyzing the bytecode of any project used with Cover. You can do this from the Maven plugin in IntelliJ - click the Maven tab, open petclinic > Lifecycle, and double-click package.

Basic prerequisites:

  • Java 8, 11, 17, or 21 compatible source code, or Kotlin source code.

  • Maven 3.2.5+ or Gradle 4.9+ build tools.

  • The project (for use with Diffblue Cover) must compile and run with no failing unit tests.

    JUnit and TestNG testing frameworks are supported.

More details:

Diffblue Cover requires that the system environment (hardware, operating system, network connectivity, Java installation) as well as the project environment (build tooling, dependencies, presence of artifacts, existing unit tests) meet the minimum requirements as detailed in Specs & Reqs. Cover Plugin will perform an environment check before analysis begins to ensure that the requirements are met - if there are any issues, these will be reported via the Diffblue Cover panel in IntelliJ using E (Environment) Output Codes.

Step 3 - A couple of basics

We won't cover the whole UI here, but here are a few useful gutter icons to get you started:

Icon
Description

Write tests - click this icon to write tests for this method or class.

Not testable - this method or class can't be tested. Click the icon to find out why.

Private method - this method can't be tested as it's private, although it may be tested indirectly via a public method. If you'd like Cover to write unit tests for this method, you can either make the method public or package protected.

Test maintenance - displayed next to test classes and methods in project test files. Click the icon to update or delete tests for the method or class.

Delete test - displayed next to your test methods in project test files. Click the icon to delete a test method.

Step 4 - Automatically write tests for the example project

  1. Navigate to a class - for example, OwnerController.

  2. Click the links in the Diffblue Cover panel to see the tests produced - example below.

And that's it, simple - 1 click, 9 methods analyzed, 7 tests written, around 340 lines of code, and all in around 65 seconds - computationally perfect, human readable.

package org.springframework.samples.petclinic.owner;

import ...

@ContextConfiguration(classes = {OwnerController.class})
@ExtendWith(SpringExtension.class)
class OwnerControllerDiffblueTest {
	@Autowired
	private OwnerController ownerController;

	@MockBean
	private OwnerRepository ownerRepository;

	/**
	 * Method under test: {@link OwnerController#initCreationForm(Map)}
	 */
	@Test
	void diffbluetestInitCreationForm() throws Exception {
		MockHttpServletRequestBuilder requestBuilder = MockMvcRequestBuilders.get("/owners/new");
		MockMvcBuilders.standaloneSetup(ownerController)
			.build()
			.perform(requestBuilder)
			.andExpect(MockMvcResultMatchers.status().isOk())
			.andExpect(MockMvcResultMatchers.model().size(1))
			.andExpect(MockMvcResultMatchers.model().attributeExists("owner"))
			.andExpect(MockMvcResultMatchers.view().name("owners/createOrUpdateOwnerForm"))
			.andExpect(MockMvcResultMatchers.forwardedUrl("owners/createOrUpdateOwnerForm"));
	}

....

Note that the examples here use DiffblueTest as the default class name suffix and diffbluetest as the default method name prefix, just to highlight the tests created by Diffblue Cover. To change your suffix and prefix in IntelliJ, go to Diffblue > Change Settings > Test Naming > Class Template/Method Template.

More...

What does the plugin do?

  • Diffblue Cover first ensures that your code is compiled and examines each method that Cover will create tests for, including any dependent methods.

  • Cover then creates initial test candidates and uses reinforcement learning to evaluate and adjust the test candidate for each method. This process is repeated until the set of tests that optimize coverage are selected and committed to your code base.

More tests

This simple "getting started" example illustrates creating tests for a class using the gutter icons (you can do the same for individual methods too). You can scale this up even further - right-click a Java source file or folder in your project structure and select Write Tests to create tests for all classes/methods contained within the file/folder. Of course that may not always be desirable:

  • A large project with potentially a large number of tests can take some time to complete.

  • License limits may apply.

Next steps

Now you're up and running with Cover Plugin:

  • Have a scan through the Test examples topic which provides some additional source code examples along with an explanation of the tests created by Diffblue Cover.

  • Select your own preferences/settings for Cover Plugin - go to Diffblue > Change Settings.

  • See Cover Plugin to familiarize yourself with the full set of plugin features and functions.

Diffblue Cover - one AI

Diffblue Cover is also provided as a CLI tool to write tests for your entire project, all in one hit (see Get started - Cover CLI), and can also be integrated into your CI pipeline to automatically write tests within your CI workflow (see Get started - Cover Pipeline).

But Cover CLI, Cover Plugin, and Cover Pipeline are not mutually exclusive, in fact they make perfect partners. Use Cover Plugin within the IntelliJ IDE to write and check unit tests for your application during development, and also use Cover CLI directly from the IntelliJ Console or your OS command line to access the wider and deeper functionality provided by Cover CLI - finally, use Cover Pipeline within your CI tool to automate the whole process and provide consistency across your organization.

Download the Diffblue Cover Plugin for IntelliJ as a .zip bundle from: - The Diffblue website - or versions. - The (IntelliJ Plugin Marketplace). - The link sent to you via your Diffblue Cover welcome email. - Your organization's internal file/app store.\

Note that you can run dcover create --preflight (using ) to check the Cover prerequisites for your project, without performing any other actions.

To create tests for this class, click on the Write Tests gutter icon next to the line class OwnerController.

Create some tests for your own project - as long as you have a project that compiles and your environment meets the Cover , you're literally a click away from AI written tests, created in seconds instead of hours.

Free Community Edition
Free Trial
JetBrains Marketplace
Diffblue Cover CLI
prerequisites