Building a Gradle project
Tips for successfully building a Gradle project (in order to use Diffblue Cover CLI it is essential that your Gradle project builds successfully). Some troubleshooting tips too.
If your project uses the Gradle build system,
cdinto the directory containing the build script (
build.gradle.kts) for the module you wish to build.
For a single-module project, this is typically located at the root of your repository. For a multi-module project, this may be within a sub-directory.
To compile the project, if a
gradlew.baton Windows) file is present, run the
./gradlew buildcommand, otherwise run
It is generally preferable to execute Gradle commands using
gradlew.baton Windows) rather than
gradleif these Gradle wrapper scripts are present in your project.
In either case, if successful, you should see a
BUILD SUCCESSFULmessage 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.bat), Cover will use the wrapper's declared version in preference to your system's installed Gradle version.
--defineoption allows the user to pass additional system properties to
dcoverfor test creation and execution.
Any created tests may depend upon these user-specified system properties and may not execute successfully without them.
You can overcome this issue with additional configuration. If you have supplied these system properties to
dcover create -Dproperty1=value1 -Dproperty2=value2
Then you must also supply those same system properties to
Gradletest execution before running
Specify your system properties in the
systemProperty 'property1', 'value1'
systemProperty 'property2', 'value2'
When using JUnit Jupiter,
dcoverrelies upon the JUnit Platform Launcher jar to verify created tests. Without this jar
dcoverwill 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-launcherfor your JUnit engine at test runtime:
dcovercannot verify the tests it creates due to an incompatibility with the stylecheck used in your environment, you will receive an error message.
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:
options.debug = true
options.isDebug = true
javacJava compiler can use a
-goption to generate all debugging information, if you're using custom compiler arguments then please ensure the
-goption and not