Configuring Cover to work with your project's build system

Cover CLI needs to work in concert with your project's build system, for example to build your project, run tests, apply style checks to the created tests, etc. At the moment, Cover supports Maven and Gradle build systems. For most projects, Cover needs no help talking to the project's build system and everything works smoothly out of the box. However, we understand that the build system configuration for a project can get complicated. Here we describe a convenient way to configure how Cover invokes your project's build system.

Overview

Cover CLI invokes project's build system at various points of execution, so called phases:

PhasePurpose

info

Discover information about the layout and settings of the project.

launcher

Download the relevant JUnit Jupiter Launcher (for Gradle only).

clean

Remove all previously generated classes, (coverage) reports, etc.

build

Builds the project, including test-sources.

test

Execute the unit tests.

coverage

Computes coverage of the tests.

refactor

Applies any changes that we’ve detected can be applied automatically.

validate

Execute all unit/integration tests.

By default, Cover has pre-defined commands that it invokes in each of these phases. You can run dcover build-debug to see the commands for each phase.

You can customise these commands by creating a file called DiffblueBuild.yaml or DiffblueBuild.yml in the root of your project or a module. Note that by defining your own configuration file you override the default behaviour of Cover and therefore your file must specify all the interactions between Cover and your project's build system. Here is the minimum configuration that will be accepted by Cover (all the blocks below are required):

DiffblueBuild.yaml
meta:
  version: 1
  toolName: my-special-maven
cmd:
  windows:
    - mvn.cmd
  linux:
    - mvn
  macos:
    - mvn
global:
  timeout: PT1M
phase:
  info: ~
  launcher: ~
  clean: ~
  build: ~
  test: ~
  coverage: ~
  refactor: ~
  validate: ~

This example, while valid, won’t work as it doesn't execute any commands (all phases are a no-op ~). See the Quick guide to learn how to set up the most common customisations. For more information about the structure of the DiffblueBuild.yaml file, see Configuration file in detail. Finally, to see the default configuration used by Cover out of the box, see Default configuration.

Last updated