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
  • Prerequisites
  • License activation
  • Telemetry configuration
  • Make your project Cover-ready
  • Create your unit test baseline
  • What does Cover CLI do?
  • Understanding Cover's log output
  • Overview of CLI options
  • What does Cover do during test generation?
  • Understanding Cover's output codes
  • What does test validation do?
  • Coverage measurement
  • How to ask for support
  • Worked example: Baseline creation process using the Petclinic demo project

Was this helpful?

Export as PDF
  1. EVALUATION & ONBOARDING
  2. Jumpstart
  3. Phase 1: Up and running

Module 1: Create your Cover unit test baseline

PreviousPhase 1: Up and runningNextModule 2: Cover Pipeline CI integration

Last updated 8 months ago

Was this helpful?

In this module, we will enable you to perform the first steps of onboarding a new project. These are:

  1. make your first projects Cover-ready by validating the build configuration with respect to unit testing, and

  2. write a test baseline for your first projects

Prerequisites

To start this module, you need to satisfy the , which amount to having Cover installed at least to the level of , i.e.

  • on a central server.

  • As a champion you have Cover CLI installed in a development environment that satisfies the requirements.

  • You have run preflight and sent the log files to Diffblue.

License activation

using the license key that you received from the contact for software and license distribution in your organization:

dcover activate XXXX-XXXX-XXXX-XXXX

View your license details to check that the activation was successful:

dcover license

Telemetry configuration

We will check that telemetry is correctly configured on your system.

Usage information is sent to

  • External Diffblue telemetry server (Enterprise Edition users can opt out)

  • Cover Reports (if configured)

  • ~/.diffblue/telemetry.properties, or

  • Environment variables

Check that:

  • External telemetry is configured according to your company policies.

  • Cover Reports telemetry points to your central Cover Reports server.

Make your project Cover-ready

We will work through the whole flow for creating baseline tests.

If your project has multiple modules we recommend that you start with a representative module. Once the selected module is working, repeat the steps on the other modules.

We will start with the validation of your build configuration - and fixing it if necessary. We will also measure and upload your existing unit test coverage.

Step
Command

1. Build the project from its root

E.g. ./mvnw install -DskipTests

2. Check and fix the project environment

If necessary, apply manual fixes to your build configuration

3. Commit fixes

As soon as preflight doesn't report any errors or warnings:

git checkout -b diffblue-baseline

git commit -a -m "Build configuration fixes for Diffblue"

4. Measure and upload existing coverage

View Cover Reports

Create your unit test baseline

We are now ready to create the baseline tests.

Step
Command

5. Create the baseline tests and measure coverage

6. Commit the baseline tests

git add `find . -name '*DiffblueTest.java'`

git commit -m "Diffblue baseline tests"

7. Upload the baseline coverage

8. Review results

View Cover Reports

View created tests in IntelliJ

9. Push the changes

git push --set-upstream origin diffblue-baseline

Create a pull request and get it merged.

What does Cover CLI do?

When running a Cover command, the execution proceeds in several phases.

Phase
Description
Additional execution information

Detecting environment

Every Cover command starts by performing environment health checks to detect whether the project environment is ready for the Cover command to run.

Creating tests

This phase performs the generation of tests class per class, method per method.

Ends with a summary with number of tests created and issues encountered.

Validating tests

This phase validates the created tests, i.e. it removes non-compiling and failing tests.

Calculating coverage

This phase calculates the coverage of manually written and Diffblue tests using JaCoCo.

Upload to Cover Reports

This phase uploads the coverage reports to Cover Reports.

Understanding Cover's log output

Cover produces output with increasing degree of detail:

  • Console output

The log files are in the .diffblue/log directory below the directory from where Cover was run.

Overview of CLI options

The following is a short list of the more pertinent options for creating baseline tests. Details of additional options can be found in the Commands & Arguments.

  • CLI help: dcover help create

What does Cover do during test generation?

To generate tests, Cover analyzes your project's bytecode. It runs your code, and thus operates in a sandbox. The sandbox runs in a separate service process which prohibits system calls (file system, network, etc) to protect your system from potentially detrimental functionality within your codebase (e.g. wiping your filesystem, spamming third party services).

Cover partitions your code into groups of methods under test that it is going to test. For each group of methods under test, Cover

  • either produces tests

  • or an output code that explains why it didn’t produce complete tests

Understanding Cover's output codes

There are different types of messages distinguished by the first letter in the output code:

  • Informational messages:

    • Testability (T), reason for not writing tests (R)

  • Warnings/errors:

    • Project environment (E) including coverage measurement and reports upload

    • Licensing (L)

What does test validation do?

Validation ensures that generated tests compile and pass. This is essential for Cover's autonomous operation in your CI Pipeline.

You may see two output codes related to test validation:

  • First, tests are compiled and run individually (W output code).

  • Finally, tests are run via your build system (V output code).

Coverage measurement

Cover uses JaCoCo for coverage measurement.

Cover distinguishes two types of tests:

  • Diffblue-controlled tests (“Diffblue”)

    • Unchanged tests written by Cover

    • Automatically maintained by CI pipeline

  • User-controlled tests (“manual”)

    • Manually written or modified Diffblue tests

    • Maintained by user

    • These include the existing tests that you have manually written before starting to use Cover.

How to ask for support

Before reaching out, check for potential solutions in

Requirements for Diffblue to handle your support case:

  • Detailed description of what you did and the behavior you observe (compared with what you expect)

      • A reproducer (most valuable to be able to support): a piece of code that results in the the R code message that you see

Worked example: Baseline creation process using the Petclinic demo project

The prerequisites for running this example are:

  • JDK 17 has been installed.

We will work through the whole flow for creating baseline tests.

Step
Command

1. Build the project from its root

./mvnw install -DskipTests

2. Check and fix the project environment

dcover create --preflight

dcover fix-build

3. Commit fixes

git checkout -b diffblue-baseline

git commit -a -m "Build configuration fixes for Diffblue"

4. Measure and upload existing coverage

dcover coverage-reports

dcover upload http://localhost:8080

5. Create the baseline tests and measure coverage

dcover create --coverage-reports

6. Commit the baseline tests

git add `find . -name '*DiffblueTest.java'`

git commit -m "Diffblue baseline tests"

7. Upload the baseline coverage

dcover upload http://localhost:8080

8. Review results

View created tests in IntelliJ

9. Push the changes

We skip this step for the demo project.

via one of

You can find a worked example of the entire flow .

Note that you can run a specific module without changing your working directory by adding the following option to the dcover commands: your-selected-module

dcover create

dcover

dcover

dcover http://your-cover-reports:8080

dcover

dcover http://your-cover-reports:8080

When using , Cover stops after this phase and outputs an environment summary.

Only executed when using the command.

Executed after test generation when using the command.

Test validation can also be run separately using the command.

Executed when passing the option to the command.

Coverage reports can also be generated separately using the command.

Executed when running the command.

Console output with

Select module to run on without changing directory, e.g. my-module/my-submodule

Exclude modules, e.g. my-module/to-exclude

Verbose console output:

Prefer Maven over Gradle:

Test framework, e.g. junit-4

Active Spring profiles, e.g. test

Ignore style checks:

System properties, e.g. my.property=value

Environment variables, e.g. MYVAR=value

Cover automatically figures out which entry point methods to write tests for. The set of methods can be restricted by . E.g. to write tests only for the OwnerController class you can run dcover create org.springframework.samples.petclinic.owner.OwnerController

Output codes identify the , e.g. E052 - Missing dependency

The output code can be used to quickly look it up in docs: e.g.

and

More complex questions & issues .

Diffblue Cover

Additionally, for -related questions, one of the following:

A code snippet of the relevant code under test (useful, but with lower chances of success) and a (if there is one) with the R code

, and started by running bin/cover-reports

The demo project has been cloned by running git clone

To use the dcover fix-build command in step 2, must be met.

Telemetry is configured
--working-directory
--working-directory
--exclude-modules
--maven
--test-framework
--active-profiles
--ignore-stylechecks
-D
--environment
specifying inclusions and exclusions
messages that Cover outputs
https://diff.blue/E052
the documentation
the forum
contact support depending on your support plan
R code
partial test
Cover Reports has been downloaded, unpacked locally
https://github.com/diffblue/demo-spring-petclinic
here
--preflight
fix-build
coverage-reports
upload
create
--coverage-reports
upload
--preflight
create
create
validate
--coverage-reports
create
coverage-reports
upload
View Cover Reports
View Cover Reports
prerequisites
Cover Reports is installed
Reference Deployment 1
these prerequisites
User log file
Support log file
support log file
Activate Cover CLI
--verbose
--verbose