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
  • Compiling the project
  • Gradle and user-specified system properties
  • Gradle Troubleshooting
  • JUnit Jupiter Platform Launcher jar
  • Checkstyle Plugin
  • Debugging Information

Was this helpful?

Export as PDF
  1. Features
  2. Cover CLI
  3. Project configuration
  4. Compiling your project successfully

Building a Gradle project

PreviousBuilding a Maven projectNextConfiguring Cover to work with your project's build system

Last updated 7 months ago

Was this helpful?

Tips for successfully building a Gradle project - an essential prerequisite for using Cover CLI.

Compiling the project

If your project uses the Gradle build system, cd into the directory containing the build script (build.gradle or build.gradle.kts), this is typically located at the root of your repository.

To compile the project, if a gradlew (or gradlew.bat on Windows) file is present, run the ./gradlew build command, otherwise run gradle build.

It is generally preferable to execute Gradle commands using ./gradlew (or gradlew.bat on Windows) rather than gradle if these Gradle wrapper scripts are present in your project.

In either case, if successful, you should see a BUILD SUCCESSFUL message towards the end of the output from Gradle:

BUILD SUCCESSFUL in 15s
7 actionable tasks: 2 executed, 5 up-to-date

In order to run Diffblue Cover CLI it is essential that your Gradle project builds successfully. If it finds a Gradle project, Cover will call Gradle to determine your project settings. If your Gradle project fails then Cover will exit with an error message (and reason):

ERROR An error was encountered while building the Gradle project at ...

If there is a Gradle wrapper for your project (gradlew, gradlew.bat), Cover will use the wrapper's declared version in preference to your system's installed Gradle version.

Gradle and user-specified system properties

The -D or --define option allows the user to pass additional system properties to dcover for test creation and execution.

Any created tests may depend upon these user-specified system properties and may not execute successfully without them.

Unfortunately by default Gradle does not forward command line system properties to test execution. Therefore out-of-the-box dcover may fail to .

You can overcome this issue with additional configuration. If you have supplied these system properties to dcover:

dcover create -Dproperty1=value1 -Dproperty2=value2

Then you must also supply those same system properties to Gradle test execution before running dcover create.

Specify your system properties in the test task:

test {
  systemProperty 'property1', 'value1'
  systemProperty 'property2', 'value2'
}
tasks {
  test {
    systemProperty("property1", "value1")
    systemProperty("property2", "value2")
  }
}

Gradle Troubleshooting

JUnit Jupiter Platform Launcher jar

When using JUnit Jupiter, dcover relies upon the JUnit Platform Launcher jar to verify created tests. Without this jar dcover will not be able to verify that created tests execute successfully in your build environment. You may see this warning message if the launcher jar is not available from your test configuration:

13:11:32.487 INFO Checking test environment...
13:11:39.515 ERROR E011: Problems in the local build environment have been detected that will prevent Diffblue Cover from validating the generated tests.

To prevent this issue you must configure your build script to supply the corresponding junit-platform-launcher for your JUnit engine at test runtime:

dependencies {
  testImplementation("org.junit.jupiter:junit-jupiter-api:5.7.1")
  testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:5.7.1")
  testRuntimeOnly("org.junit.platform:junit-platform-launcher:1.7.1")
}

Checkstyle Plugin

If dcover cannot verify the tests it creates due to an incompatibility with the stylecheck used in your environment, you will receive an error message.

tasks.withType(Checkstyle) {
    exclude '**/*DiffblueTest**'
}
tasks.withType<Checkstyle> {
  exclude("**/*DiffblueTest**")
}

Debugging Information

Class files should be compiled with debug information included for Diffblue Cover to write the best tests possible. If you have switched off debug information, please switch it back on again:

tasks.withType(JavaCompile) {
  configure(options) {
    options.debug = true
  }
}
tasks.withType<JavaCompile> {
  options.isDebug = true
}

The underlying javac Java compiler can use a -g option to generate all debugging information, if you're using custom compiler arguments then please ensure the -g option and not -g:none are present.

Keeping these properties in sync will ensure that will succeed and that your created tests can be executed successfully from Gradle.

In the example above 1.7.1 is the correct version of the platform launcher for the 5.7.1 version of the engine. See the for further details about this.

If your project uses the Gradle Checkstyle plugin (), amend the build script to exclude Diffblue tests, as shown in the example below:

For Gradle documentation, see .

validate your tests
test validation
JUnit user guide
https://docs.gradle.org/current/userguide/checkstyle_plugin.html
CompileOptions