Test framework dependencies

Tests created by Diffblue Cover make use of a testing framework, namely one of JUnit 4, JUnit Jupiter, or TestNG - these frameworks are included in the required dependencies below. These dependencies are available from the Maven Central Repository. To add it, follow the guide relevant to your build tool.

Maven

Check whether or not the test framework dependencies are already in your Maven project. If not, follow the instructions below to add it:

  1. Edit the pom.xml

  2. Add the surefire pluginarrow-up-right to the build plugins section

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <version>3.5.4</version>
        </plugin>
    </plugins>
</build>
circle-info

With recent versions of surefire, it is not necessary to specify any plugin dependencies for the specific testing framework being used; surefire will detect the versions specified in the project dependencies section as specified below.

circle-info

Explicitly specifying a testing framework in the plugin dependencies (e.g. to override the provider) can result in a reduced capability in the surefire plugin. In some cases, this can prevent Cover from grouping tests correctly which affects coverage calculations.

  1. Add JUnit or TestNG to the dependencies section:

For JUnit 4:

For JUnit Jupiter 5:

For TestNG:

Gradle

Check whether or not the test framework dependencies are already in your Gradle project. If not, follow the instructions below to add it:

  1. Edit the build script (build.gradle or build.gradle.kts).

  2. Add Maven to the repositories section.

  3. Add JUnit or TestNG to the dependencies section:

For JUnit 4:

For JUnit Jupiter 5:

For TestNG:

circle-info

The versions specified are the latest at the time of writing. Please use the latest versions available for the best results

Last updated

Was this helpful?