# Free trial

Trying out Diffblue Cover for the first time? Get up and running with the trial version of Cover Plugin for IntelliJ and Cover CLI – download, install, license, and play.

## eLearning

**Short on time?** If you'd like a fast-track experience check out our free trial experience video. \[7 min]

{% embed url="<https://youtu.be/CnDKtCrwnrI>" %}

## A few points first...

#### Cover components

Cover is provided as an IDE plugin tool so you can write tests with one click in the IntelliJ IDE (Cover Plugin), a CLI application to write tests for your entire project (Cover CLI), and a CI integration to automatically write tests within your CI workflow (Cover Pipeline).

#### Perfect partners

Cover Plugin, Cover CLI, 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 Terminal/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 organisation.

#### The free trial

This topic focuses on Cover Plugin and Cover CLI, and will take you through the key steps to download, install, and license both tools, as well as covering a few basics and getting some tests written using each tool. Cover Pipeline for GitLab is also available as a free trial version, see [cover-pipeline-for-gitlab](https://cover-docs.diffblue.com/features/cover-pipeline/cover-pipeline-for-gitlab "mention") for details - for all other CI integrations please [contact](https://www.diffblue.com/contact/) Diffblue.

<div align="left"><figure><img src="https://1243928156-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FZ7l8pn8qoIC3ubiJzuaF%2Fuploads%2Fgit-blob-4dd552d515d6ab2cd5fa71040f826fafb3e5113f%2FWorkflow-PluginCLI-CIFade-2024.jpg?alt=media" alt="" width="375"><figcaption></figcaption></figure></div>

## 1. Sign up

If you haven't already done so, sign up for the free trial - see <https://www.diffblue.com/try-cover>.

After successful sign-up, you'll receive a welcome email with general information and a license key for Cover Plugin and Cover CLI.

## 2. Install Cover Plugin for IntelliJ

You can install the Cover Plugin either from a downloaded ZIP archive or from the IntelliJ marketplace.

{% tabs %}
{% tab title="From a ZIP Archive" %}

1. Download the Diffblue Cover Plugin for IntelliJ as a `.zip` bundle from:\
   \
   \&#xNAN;**-** The Diffblue website - [Free Community Edition](https://www.diffblue.com/community-edition/download) or [Free Trial](https://www.diffblue.com/try-cover) versions.\
   \
   \&#xNAN;**-** The [JetBrains Marketplace](https://plugins.jetbrains.com/) (IntelliJ Plugin Marketplace).\
   \
   \&#xNAN;**-** The link sent to you via your Diffblue Cover welcome email.\
   \
   \&#xNAN;**-** Your organization's internal file/app store.\\
2. In the IntelliJ IDE, open the `Plugins` menu - either `File > Settings > Plugins` (Windows/Linux) or `IntelliJ IDEA > Preferences > Plugins` (macOS).
3. 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`.
4. When prompted, click `Restart IDE` to complete the install.

<div align="left"><figure><img src="https://1243928156-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FZ7l8pn8qoIC3ubiJzuaF%2Fuploads%2Fgit-blob-a628ab6d7832cd6326dea7e0e4634e16337423a3%2FIDEPluginZip.jpg?alt=media&#x26;token=6b43e7a8-7742-4929-ab87-a6f1632c3412" alt="" width="266"><figcaption></figcaption></figure></div>
{% endtab %}

{% tab title="From IntelliJ IDE" %}

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.

<div align="left"><figure><img src="https://1243928156-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FZ7l8pn8qoIC3ubiJzuaF%2Fuploads%2Fgit-blob-b5acf0d08169ecbcb27c570800ff3a9fcf4a0abe%2FIDEPluginMenu.jpg?alt=media&#x26;token=99e0d6a6-a52e-458e-99d8-c468cd6a8d0b" alt="" width="563"><figcaption></figcaption></figure></div>
{% endtab %}
{% endtabs %}

## 3. Install Cover CLI

{% tabs %}
{% tab title="Windows" %}

1. Download the Diffblue Cover CLI `.exe` installer or `.zip` file from:\
   \
   \&#xNAN;**-** The Diffblue website - [Free Trial](https://www.diffblue.com/try-cover) version.\
   \
   \&#xNAN;**-** The link sent to you via your Diffblue Cover welcome email.\
   \
   \&#xNAN;**-** Your organization's internal file/app store.\\
2. If you use the installer, run the `.exe` installer and follow the on-screen prompts - during installation you can select where to install Diffblue Cover.
3. If you use the archive file, extract the `.zip` file to an appropriate installation folder. Add the install folder path to your the `PATH` environment variable or create a new `%DCOVER%` environment variable and add that to `PATH`.
4. When your done, restart your PC. Once complete, open Windows PowerShell and enter `dcover version` to check the install and `PATH` configuration - if all is OK, Cover will display the current version.
   {% endtab %}

{% tab title="Linux/macOS" %}

1. Download the Diffblue Cover CLI `.zip` file from:\
   \
   \&#xNAN;**-** The Diffblue website - [Free Trial](https://www.diffblue.com/try-cover) version.\
   \
   \&#xNAN;**-** The link sent to you via your Diffblue Cover welcome email.\
   \
   \&#xNAN;**-** Your organization's internal file/app store.\\
2. Unzip the Cover CLI zip file to an appropriate installation location (for example, `~/bin`) and add this location in the `PATH` environment variable using the following example commands:\\

   ```
   mkdir ~/bin
   cd ~/bin
   unzip ~/diffblue-cover*.zip
   export PATH=$PATH:~/bin
   ```

   \
   **Reminder:** Make sure that the `PATH` environment variable is set permanently according to your operating system instructions.
3. Once complete, run `dcover version` to check the install and `PATH` configuration - if all is OK, Cover will display the current version.
   {% endtab %}
   {% endtabs %}

## 4. Apply licenses

{% tabs %}
{% tab title="Cover Plugin" %}
Once IntelliJ has restarted (after install), you'll be prompted for your license key (provided in your welcome email or by your organization) to activate the plugin. 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](https://cover-docs.diffblue.com/get-started/licensing "mention"). 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](https://cover-docs.diffblue.com/updates-and-upgrades/cover-editions "mention") and [licensing](https://cover-docs.diffblue.com/get-started/licensing "mention") for more details.

<figure><img src="https://1243928156-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FZ7l8pn8qoIC3ubiJzuaF%2Fuploads%2Fgit-blob-d81b044fc81f743a1562fc9d7008b793200fc310%2Fimage%20(25)%20(1).png?alt=media" alt="" width="563"><figcaption></figcaption></figure>
{% endtab %}

{% tab title="Cover CLI" %}
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, as well as details of offline licensing (Enterprise Edition only), see [licensing](https://cover-docs.diffblue.com/get-started/licensing "mention").

* To activate your license, open Windows PowerShell (Windows) or Terminal (macOS/Linux) and enter the command `dcover activate <license-key>` - replace `<license-key>` with the license key provided in your welcome email or provided by your organization.
* Entering multiple different license keys will overwrite the existing key.
* You can check your license status by running the command `dcover license`
  {% endtab %}
  {% endtabs %}

## 5. 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:

{% tabs %}
{% tab title="Git CLI" %}

1. Open a command line and navigate to where you want to clone this project.
2. Run the following command:

```
git clone https://github.com/diffblue/demo-spring-petclinic
```

{% endtab %}

{% tab title="IntelliJ UI" %}
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`.

<div align="left"><figure><img src="https://1243928156-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FZ7l8pn8qoIC3ubiJzuaF%2Fuploads%2Fgit-blob-7291c15df555939f4ee3f9f2dca577882fca0bbc%2FIDEClonePetclinic.jpg?alt=media&#x26;token=1517f9f0-f848-409e-9abf-3f4e4886fd72" alt="" width="375"><figcaption></figcaption></figure></div>
{% endtab %}
{% endtabs %}

### 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`) or open a command line, navigate to the directory containing the PetClinic project, and run the Maven `package` command:

```
cd demo-spring-petclinic
./mvnw 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.
* Any 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-and-reqs](https://cover-docs.diffblue.com/get-started/specs-and-reqs "mention"). Cover 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](https://cover-docs.diffblue.com/features/output-codes "mention").

**Check your environment:**

Cover CLI also provides a command line option to run these checks, without writing any tests, useful when you just want to check-out your environment without doing anything else. To run a preflight environment check, open a command line, navigate to the directory containing the PetClinic project, and run the preflight checks:

```
cd demo-spring-petclinic
dcover create --preflight
```

### Step 3 - A few basics

Before we start using Diffblue Cover to write tests, it's worth covering a few basics first.

{% tabs %}
{% tab title="Cover Plugin" %}
We won't cover the whole UI here, but here are a few useful gutter icons to get you started:

<table><thead><tr><th width="94.08517077388666">Icon</th><th>Description</th></tr></thead><tbody><tr><td><img src="https://1243928156-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FZ7l8pn8qoIC3ubiJzuaF%2Fuploads%2Fgit-blob-86e7d4edd8c331b412648a612f2b81a2448ee5ef%2FwriteTestsLight.svg?alt=media&#x26;token=f253793e-80f9-4e6f-adc8-996ffb4718b8" alt=""></td><td><strong>Write tests</strong> - click this icon to write tests for this method or class.</td></tr><tr><td><img src="https://1243928156-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FZ7l8pn8qoIC3ubiJzuaF%2Fuploads%2Fgit-blob-7ab1611e83b3385f18a779e5427f4c35000d21fb%2FuntestableLightWithBackground%20(1).svg?alt=media" alt=""></td><td><strong>Not testable</strong> - this method or class can't be tested. Click the icon to find out why.</td></tr><tr><td><img src="https://1243928156-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FZ7l8pn8qoIC3ubiJzuaF%2Fuploads%2Fgit-blob-355dd312ec34756c4ecaa16c05fec7bc4d1cc0e5%2FuntestableByDesignLightWithBackground%20(1).svg?alt=media" alt=""></td><td><strong>Private method</strong> - 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.</td></tr><tr><td><img src="https://1243928156-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FZ7l8pn8qoIC3ubiJzuaF%2Fuploads%2Fgit-blob-aac868fedbbadd4492bf9e0d979c14b8490dc30a%2FtestMaintenanceLight.svg?alt=media&#x26;token=3b59a038-10d7-4d5e-9e7d-f9a06faf2504" alt=""></td><td><strong>Test maintenance</strong> - displayed next to test classes and methods in project test files. Click the icon to update or delete tests for the method or class.</td></tr><tr><td><img src="https://1243928156-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FZ7l8pn8qoIC3ubiJzuaF%2Fuploads%2Fgit-blob-e23995e7953217cf3ca5c8fe08f40463977d7a6a%2FdeleteTestsLight.svg?alt=media&#x26;token=ac8e8bb6-24b8-4361-9e78-e20788e543d1" alt=""></td><td><strong>Delete test</strong> - displayed next to your test methods in project test files. Click the icon to delete a test method.</td></tr></tbody></table>
{% endtab %}

{% tab title="Cover CLI" %}
We won't cover every CLI command option, but here are a few details to get you started:

<table><thead><tr><th width="216.74566473988432">Command</th><th>Description</th></tr></thead><tbody><tr><td><code>dcover help</code></td><td><strong>Help</strong> - get, err, help. Use this with the other commands as well to get some details of what options are available (like <code>dcover create help</code> to get details of the available optional arguments).</td></tr><tr><td><p><code>dcover activate</code></p><p><code>&#x3C;license-key></code></p></td><td><strong>Activate License</strong> - apply/activate a license. Replace <code>&#x3C;license-key></code> with the license key provided in your welcome email or provided by your organization.</td></tr><tr><td><code>dcover license</code></td><td><strong>Check License</strong> - display your current license status.</td></tr><tr><td><code>dcover version</code></td><td><strong>Check Version</strong> - display the version of Diffblue Cover CLI.</td></tr><tr><td><code>dcover create</code></td><td><strong>Create Tests</strong> - write tests for the project (run from the root directory of the project). You can restrict this further by simply specifying the method or class path - this is detailed a little further in the example in Step 4 below.</td></tr><tr><td><code>dcover create</code><br><code>--&#x3C;arguments></code></td><td><strong>Optional Arguments</strong> - there's a few, OK quite a lot. The optional arguments provide access to deeper functionality within Cover CLI such as creating coverage reports, specifying a build configuration file, and running preflight checks (this one is used in Step 3 below).</td></tr></tbody></table>
{% endtab %}
{% endtabs %}

### Step 4 - Automatically write tests for the example project

In this step we're going to use Diffblue Cover to automatically write tests for two classes and then for the entire PetClinic project. We'll make use of Cover Plugin for IntelliJ and run Cover CLI commands from a command line. You can also use Cover CLI straight from the IntelliJ terminal - handy when you’re using both tools in partnership

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`.
* To change your suffix and prefix in Cover CLI, use the `--class-name-template` and `--method-name-template` command arguments - see Cover CLI [commands-and-arguments](https://cover-docs.diffblue.com/features/cover-cli/commands-and-arguments "mention") for details.

***

**First we'll use Cover Plugin for IntelliJ:**

1. In IntelliJ, open the PetClinic project and navigate to a class - for example, `OwnerController`.
2. To create tests for this class, click on the <img src="https://1243928156-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FZ7l8pn8qoIC3ubiJzuaF%2Fuploads%2Fgit-blob-675828c7c925ab0da8312e3d1c7f10ff094e639e%2Fwritetestslight%20(1).png?alt=media" alt="" data-size="line"> `Write Tests` gutter icon next to the line `class OwnerController`.
3. Click the links in the Diffblue Cover panel to see the tests produced. 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. You'll find these tests in the `test` folder for the project.

```java
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"));
	}

....
```

***

**Now we'll move on to using Cover CLI.**

1. Open a command line or open the IntelliJ terminal, and navigate to the demo-spring-petclinic folder.
2. Enter the following command to write tests for the `PetController` class:

```
dcover create org.springframework.samples.petclinic.owner.PetController
```

3. Cover CLI will now write the tests for the class - 1 command line, 10 methods analyzed, 9 tests written, around 214 lines of code created, and again, all in around 65 seconds - computationally perfect, human readable. You'll find these tests in the `test` folder for the project.

```java
package org.springframework.samples.petclinic.owner;

import ...

@ContextConfiguration(classes = {PetController.class})
@ExtendWith(SpringExtension.class)
class PetControllerDiffblueTest {
	@MockBean
	private OwnerRepository ownerRepository;

	@Autowired
	private PetController petController;

	/**
	 * Method under test: {@link PetController#populatePetTypes()}
	 */
	@Test
	void diffbluetestPopulatePetTypes() {
		ArrayList<PetType> petTypeList = new ArrayList<>();
		when(ownerRepository.findPetTypes()).thenReturn(petTypeList);
		Collection<PetType> actualPopulatePetTypesResult = petController.populatePetTypes();
		assertSame(petTypeList, actualPopulatePetTypesResult);
		assertTrue(actualPopulatePetTypesResult.isEmpty());
		verify(ownerRepository).findPetTypes();
	}
....
```

4. Once you're happy with this first set of tests, create the full test suite for the entire PetClinic project - enter `dcover create`. That's it, two "words" and you're done. Of course this one takes a **little** longer to complete (around five minutes) as it creates tests across the entire PetClinic project, analyzing 97 methods and creating 77 tests (exact count may vary slightly).

## More...

### What does Diffblue Cover do?

<div align="left"><figure><img src="https://1243928156-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FZ7l8pn8qoIC3ubiJzuaF%2Fuploads%2Fgit-blob-84f1e2ad9e35e66fafbeb7a6b37c352a47bb8502%2FDiffblueCoverCoreProcess-2024.jpg?alt=media" alt=""><figcaption></figcaption></figure></div>

* 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.

### Next steps

Now you're up and running with Diffblue Cover:

* Have a scan through the [test-examples](https://cover-docs.diffblue.com/features/cover-plugin/writing-tests/test-examples "mention") topic which provides some additional source code examples along with an explanation of the tests created by Diffblue Cover.
* Create some tests for your own project - as long as you have a project that compiles and your environment meets the Cover [prerequisites](https://cover-docs.diffblue.com/get-started/specs-and-reqs), you're literally a click away from AI written tests, created in seconds instead of hours.
* See [cover-plugin](https://cover-docs.diffblue.com/features/cover-plugin "mention") and [cover-cli](https://cover-docs.diffblue.com/features/cover-cli "mention") to familiarize yourself with the full set of features and functions.
* Cover Pipeline for GitLab is also available as a free trial version, see [cover-pipeline-for-gitlab](https://cover-docs.diffblue.com/features/cover-pipeline/cover-pipeline-for-gitlab "mention") for details - for all other CI integrations please [contact](https://www.diffblue.com/contact/) Diffblue.

{% hint style="info" %}
If you're only planning to use Cover Plugin Community Edition (free), you may just want to jump straight to the topic.
{% endhint %}

### Notes

> Demo code, statistics, and timings used throughout Diffblue docs and eLearning videos are based on in-house demonstrations. These may differ slightly from those experienced within a live production environment.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://cover-docs.diffblue.com/get-started/get-started/free-trial.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
