Generate and upload reports bundles

Cover Reports data, referred to as "reports bundles", are generated as part of your code development process and uploaded to Cover Reports. This can be done from Cover CLI and/or Cover Pipeline, using the appropriate dcover commands detailed in this topic. Reports bundles are comprised of the following files:

  • report.json - Diffblue's coverage report.

  • diffblue-tests-jacoco-report.xml - a JaCoCo coverage report providing data for Diffblue tests (created by Diffblue Cover).

  • manual-tests-jacoco-report.xml – a JaCoCo coverage report providing data for manual tests (created by a developer).

Reports bundles can be generated and uploaded as follows:

  • Create, Generate, Upload - create tests, generate the reports bundle, and upload the bundle to the Cover Reports server.

  • Generate Only - generate the reports bundle only, no tests created, no upload.

  • Upload Only - upload an existing reports bundle only.

The associated dcover commands can be run from Cover CLI or integrated into your CI/CD workflow/pipeline as needed.

Before generating any reports bundles, run dcover coverage-reports --preflight to check if all preconditions necessary for generating the reports are met, without creating the reports themselves.

Command summary (core options only):

// Create, Generate, and Upload
dcover create
--coverage-reports
--upload=<reports-server>

// Generate Only
dcover coverage-reports

// Upload Only
dcover upload <reports-server>

Create, Generate, Upload

This topic details the dcover command to create tests, generate the reports bundle, and upload the bundle to the Cover Reports server.

Prerequisites:

Command details:

Run the following dcover command:

dcover create
--coverage-reports
--upload=<reports-server>
--name=<name-of-report>
--project-name=<name-of-project>
--location=<report-location>
--report-username=<username>
--report-password=<password>

For example:

dcover create
--coverage-reports
--upload=http://cover-reports-service:8080
--name="Branch: 1234/feature-TG12345"
--project-name="hello-world"
--location="customer-markets.trading.name"
--report-username="myusername"
--report-password="mypassword"
ArgumentDescription

--coverage-reports

Generates the reports bundle.

--upload=<reports-server>

Uploads the reports bundle to the specified Cover Reports server. See your Cover Reports Administrator for details, if needed.

--name=<name-of-report>

Sets the name of the reports bundle. Replace <name-of-report> with a useful name. If the --name argument is omitted, the name will default to the current timestamp, or the latest commit hash when used within Git.

--project-name=<name-of-project>

Sets the specific name of the project to which this reports bundle relates. Replace <name-of-project> with a useful name. If the --project-name argument is omitted, the project name in Cover Reports will default to the project name defined by the build system, which is recommended.

--location=<report-location>

Sets the path to the project in Cover Reports. Replace <report-location> with a useful value, with folder names separated by dots. If the provided location does not exist it will be created. If the --location argument is omitted, the project will be placed in the default location. Project locations can be changed from within Cover Reports at any time.

--report-username=<username>

--report-password=<password>

Cover Reports username and password. Used for authenticated uploads only - see Authenticated uploads. The username and password must match those configured by your Cover Reports Administrator.

The --project argument (Java project name) has now been removed (Diffblue Cover release 2024.02.01 and later). Instead, the --project-name and --location arguments can be used. However, the project name is now automatically calculated based on the project configuration, and report bundles are uploaded to a default Projects folder. Any --project value provided will now be ignored. Use of --project should be avoided as this option may be fully removed in future releases.

Also, the previous --report argument has been replaced with --upload (Diffblue Cover release 2023.11.01 and later). Use of --report should be avoided as this option will be fully removed in future releases.

Optional JaCoCo arguments:

ArgumentDescription

--jacoco-command-diffblue =<command>

Custom command to generate the JaCoCo report for tests written by Diffblue Cover.

--jacoco-command-manual =<command>

Custom command to generate the JaCoCo report for manually written tests.

--jacoco-xml-test-report =<jacoco-xml-test-report>

Filename and path (including the .xml extension) of the JaCoCo report created using custom commands (as defined above).

Examples (using default values):

// jacoco-command-diffblue for Maven
--jacoco-command-diffblue="mvn clean test jacoco:report -Dtest='*DiffblueTest.java'"

// jacoco-command-diffblue for Gradle
--jacoco-command-diffblue=./gradlew test --tests=*DiffblueTest.java

// jacoco-command-manual for Maven
--jacoco-command-diffblue="mvn clean test jacoco:report -Dtest='!*DiffblueTest.java'"

// jacoco-command-manual for Gradle
--jacoco-command-diffblue=./gradlew clean test --tests=!*DiffblueTest.java

Generate Only

Generate the reports bundle only - no tests created, no upload to the server. This can be useful if tests have already been created for the project using dcover create, but the --coverage-reports option wasn't included.

Prerequisites:

Command details:

Run the following dcover command:

dcover coverage-reports

Once the reports bundle has been generated, you can upload the bundle to your Cover Reports server using dcover upload - see Upload Only below.

Optional arguments (as detailed in Commands & Arguments):

Additional JaCoCo arguments:

ArgumentDescription

--jacoco-command-diffblue =<command>

Custom command to generate the JaCoCo report for tests written by Diffblue Cover.

--jacoco-command-manual =<command>

Custom command to generate the JaCoCo report for manually written tests.

--jacoco-xml-test-report =<jacoco-xml-test-report>

Filename and path (including the .xml extension) of the JaCoCo report created using custom commands (as defined above).

Examples (using default values):

// jacoco-command-diffblue for Maven
--jacoco-command-diffblue="mvn clean test jacoco:report -Dtest='*DiffblueTest.java'"

// jacoco-command-diffblue for Gradle
--jacoco-command-diffblue=./gradlew test --tests=*DiffblueTest.java

// jacoco-command-manual for Maven
--jacoco-command-diffblue="mvn clean test jacoco:report -Dtest='!*DiffblueTest.java'"

// jacoco-command-manual for Gradle
--jacoco-command-diffblue=./gradlew clean test --tests=!*DiffblueTest.java

Upload Only

Upload an existing reports bundle only. This can be useful when the reports bundle has been generated separately, but not uploaded.

Command details:

Run the following dcover command:

dcover upload <reports-server>
--name=<name-of-report>
--project-name=<name-of-project>
--location=<report-location>
--report-username=<username>
--report-password=<password>

For example:

dcover upload http://cover-reports-service:8080
--name="Branch: 1234/feature-TG12345"
--project-name="hello-world"
--location="customer-markets.trading.name"
--report-username="myusername"
--report-password="mypassword"
ComponentDescription

dcover upload

<reports-server>

Uploads the reports bundle to the Cover Reports server. Replace <reports-server> with the URL and port number for your server - see your Cover Reports Administrator for help, if needed.

--name =<name-of-report>

Sets the name of the reports bundle. Replace <name-of-report> with a useful name. If the --name argument is omitted, the name will default to the current timestamp, or the latest commit hash when used within Git.

--project-name=<name-of-project>

Sets the specific name of the project to which this reports bundle relates. Replace <name-of-project> with a useful name. If the --project-name argument is omitted, the project name in Cover Reports will default to the project name defined by the build system, which is recommended.

--location=<report-location>

Sets the path to the project in Cover Reports. Replace <report-location> with a useful value, with folder names separated by dots. If the provided location does not exist it will be created. If the --location argument is omitted, the project will be placed in the default location. Project locations can be changed from within Cover Reports at any time.

--report-username=<username>

--report-password=<password>

Cover Reports username and password, used for authenticated uploads only. The username and password must match those configured by your Cover Reports Administrator.

The --project argument (Java project name) has now been removed (Diffblue Cover release 2024.02.01 and later). Instead, the --project-name and --location arguments can be used. However, the project name is now automatically calculated based on the project configuration, and report bundles are uploaded to a default Projects folder. Any --project value provided will now be ignored. Use of --project should be avoided as this option may be fully removed in future releases.

Additional optional arguments (as detailed in Commands & Arguments):

Additional JaCoCo arguments:

ArgumentDescription

--jacoco-report-diffblue

=<report>

Filename and path (including the .xml extension) of the JaCoCo report for Diffblue tests (if a non-standard location is used). Optional.

--jacoco-report-manual

=<report>

Filename and path (including the .xml extension) of the JaCoCo report for manually written tests (if a non-standard location is used). Optional.


Considerations

When generating, naming, and uploading reports bundles, consider the following. You may also wish to discuss these with your Cover Reports Users and Cover Reports Administrators as appropriate.

  • Generate & Upload - Timing: You can generate and upload reports bundles before, during, and after code development. For consistency, you may wish to define specific schedules and you may also find it useful to generate and upload reports for your project before you run dcover create on the project for the first time (useful for setting a coverage baseline) - see Generate Only and Upload Only.

  • Naming Conventions: The --name, --project-name and --location arguments are used to structure the uploaded data within Cover Reports. Diffblue recommends that you select an appropriate and consistent naming convention to help with data visualization in the Cover Reports UI. Alternatively, don't use these options and allow the data to be auto-generated.

  • Authentication: If upload authentication has been enabled by your Cover Reports Administrator, you'll need to use the defined username and password when uploading your reports bundles. See Authenticated uploads for details.

Last updated