Preflight checks

Diffblue Cover's preflight option checks the suitability of your environment without running a full process.
Diffblue Cover's preflight option checks the suitability of your environment without running a full process. This allows you to rectify any environmental challenges prior to attempting to test creation.

Running preflight checks

The preflight check can be run with a single dcover command from the root of the module and carries out the relevant checks. This is done by adding the option --preflight to the desired command.
The preflight check requires the all of the environmental conditions are met for running dcover:
  • Prerequisites for Cover CLI.
  • The project is built with the artifacts available.
  • Any existing tests compile and pass (for create only).
Then the command can be run, for example:
$ dcover create --preflight
The --preflight option can be added to any dcover command, for example added to the coverage-reports option as dcover coverage-reports --preflight which will carry out checks relevant to creating coverage reports (such as checking the JaCoCo plugin version) but not other checks related to test creation (such as Spring dependencies).

Understanding the environment summary

After the checks have been carried out a summary table is displayed. Several key checks, along with any warnings and errors are shown with a result of SUCCESS, WARNING or ERROR. An overall Environment check status is also given.
INFO Environment summary:
INFO --------------------
INFO Java version 11.0.14 SUCCESS
INFO Build system Gradle SUCCESS
INFO Testing framework JUnit Jupiter 5 SUCCESS
INFO Launcher JUnit Jupiter SUCCESS
INFO Test validation Enabled SUCCESS
INFO Spring Core 5.3.14 SUCCESS
WARN Spring Web 5.3.6 WARNING
INFO Spring Test 5.3.14 SUCCESS
INFO Spring Boot 2.6.2 SUCCESS
INFO Spring Boot Test 2.6.2 SUCCESS
INFO Hamcrest Hamcrest 2 2.2 SUCCESS
INFO Mocking Framework Mockito 4.0.0 SUCCESS
ERROR JVM matches compilation JDK 17 ERROR
INFO Environment check status: ERROR
Errors indicate a problem with the environment that must be corrected before the full command can be run (e.g. the current JVM does not match the compilation JDK). Warnings indicate the setup is not optimal, but they will not prevent the full command from being run (e.g. Spring dependencies are mismatched).
Detailed recommendations on how to fix the warnings and errors can be found above the summary table.
The summary table is displayed in the user log file even when a command is run without the --preflight option.

Automatic fixing of environment issues

Environment issues resulting in an R002, E027, E052, E086, E118 or E137 output code can be automatically fixed by running dcover fix-build or dcover create --fix-build. Note that an automatic fix is not always possible, especially when the project is very simple (no imports, no methods calling other methods, only primitive types, etc). See Commands & Arguments.

Running existing tests

As part of the preflight checks for dcover create, it will run the existing tests and ensure that they compile and run without any problems. This is effectively running mvn test or ./gradlew test (depending on the build system being used). It is possible to customize the commands being used along with the timeout (by default this is 30 minutes) with the --preflight-test-command and --preflight-test-timeout options respectively. It is possible to skip running the existing tests by specifying --without-tests, however doing so will result in a poor experience with dcover.