doc/integration/diffblue_cover.md
{{< details >}}
{{< /details >}}
You can integrate the Diffblue Cover reinforcement learning AI tool into your CI/CD pipelines, to automatically write and maintain Java unit tests for your GitLab projects. The Diffblue Cover Pipeline for GitLab integration allows you to automatically:
To integrate Diffblue Cover into your pipeline:
In the top bar, select Search or go to and find your project.
Select Settings > Integrations.
Find Diffblue Cover and select Configure.
Complete the fields:
Select the Active checkbox.
Enter your Diffblue Cover License key provided in your welcome email or by your organization. If needed, select the Try Diffblue Cover link to sign up for a free trial.
Enter details of your GitLab access token (Name and Secret) to allow Diffblue Cover to access your project.
In general, use a GitLab project access token with the Developer role, plus api and write_repository scopes.
If necessary you can use a group access token or a personal access token, again with the Developer role, plus api and write_repository scopes.
[!note] Using an access token with excessive permissions is a security risk. If you use a Personal access token, consider creating a dedicated user with access limited to just the project, minimizing the impact of the token being leaked.
Select Save changes. Your Diffblue Cover integration is now <mark style="color:green;">Active</mark> and ready for use in your project.
Create a merge request pipeline for the project that downloads the latest version of Diffblue Cover, builds the project, writes Java unit tests for the project, and commits the changes to the branch.
In the top bar, select Search or go to and find your project.
Copy the contents of the Diffblue-Cover.gitlab-ci.yml template
into your project's .gitlab-ci.yml file.
[!note] When using the Diffblue Cover pipeline template with your own project and existing pipeline file, add the Diffblue template content to your file and modify as needed. For more information, see Cover Pipeline for GitLab in the Diffblue documentation.
Enter a commit message.
Enter a new Branch name. For example, add-diffblue-cover-pipeline.
Select Start a new merge request with these changes.
Select Commit changes.
src/test folders in the project repository to see the unit tests created by Diffblue Cover (suffixed with *DiffblueTest.java).When performing subsequent code changes to a project, the merge request pipeline will run Diffblue Cover but will only update the associated tests. The resulting diff can then be analyzed to check the new behavior, catch regressions, and spot any unplanned behavioral changes to the code.
This topic demonstrates some of the key features of Cover Pipeline for GitLab and how to use the integration in a pipeline.
The wider and deeper functionality, provided through dcover commands in the pipeline template, can be implemented to expand your unit test capabilities even further.
For more information, see Cover Pipeline for GitLab in the Diffblue documentation.