Skip to main content

Generate unit tests

io.moderne.diffblue.GenerateUnitTests

Use the Diffblue Cover tool to generate unit tests for Java classes.

Recipe source

This recipe is only available to users of Moderne.

This recipe is available under the Moderne Proprietary License.

Options

TypeNameDescriptionExample
StringlicenseThe content of the ~/.diffblue/license.key file to use for Diffblue Cover.YOUR-LICENSE-KEY
IntegeriterationsOptional. The number of iterations to run when generating tests.1000
BooleanskipVerificationOptional. Skip verification of generated tests.false
ListargumentsOptional. Additional arguments to pass to Diffblue Cover. See the available arguments in the Cover CLI documentation.

Usage

This recipe has required configuration parameters and can only be run by users of Moderne. To run this recipe, you will need to provide the Moderne CLI run command with the required options. Or, if you'd like to create a declarative recipe, please see the below example of a rewrite.yml file:

rewrite.yml
---
type: specs.openrewrite.org/v1beta/recipe
name: com.yourorg.GenerateUnitTestsExample
displayName: Generate unit tests example
recipeList:
- io.moderne.diffblue.GenerateUnitTests:
license: YOUR-LICENSE-KEY
iterations: 1000
skipVerification: false

You will need to have configured the Moderne CLI on your machine before you can run the following command.

shell
mod run . --recipe GenerateUnitTests --recipe-option "license=YOUR-LICENSE-KEY" --recipe-option "iterations=1000" --recipe-option "skipVerification=false"

If the recipe is not available locally, then you can install it using:

mod config recipes jar install org.openrewrite.recipe:rewrite-diffblue:{{VERSION_ORG_OPENREWRITE_RECIPE_REWRITE_DIFFBLUE}}

See how this recipe works across multiple open-source repositories

Run this recipe on OSS repos at scale with the Moderne SaaS.

The community edition of the Moderne platform enables you to easily run recipes across thousands of open-source repositories.

Please contact Moderne for more information about safely running the recipes on your own codebase in a private SaaS.

Data Tables

Diffblue errors

io.moderne.diffblue.table.DiffblueErrors

The errors generated by Diffblue Cover during its attempt to generate unit tests.

Column NameDescription
Error codeThe error code returned by Diffblue Cover.
Error textThe error text returned by Diffblue Cover.