Comment on page
Gradle dependencies
How to add the test framework dependency into your Gradle build system, so the tests written by Diffblue Cover will run successfully.
After Cover Plugin has written tests for your project, they will be automatically integrated into your test suite. Before you can run the tests, you need to add any required dependencies for your particular build system.
Tests created by Diffblue Cover make use of a testing framework, namely one of JUnit 4, JUnit Jupiter, or TestNG, so 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.
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.gradleorbuild.gradle.kts). - 2.Add Maven to the
repositoriessection.repositories {mavenCentral()} - 3.Add JUnit or TestNG to the
dependenciessection:
For JUnit 4:
GROOVY
KOTLIN
dependencies {
testCompile group: 'junit', name: 'junit', version: '4.8.2'
}
dependencies {
testCompile("junit:junit:4.8.2")
}
For JUnit Jupiter 5:
GROOVY
KOTLIN
dependencies {
testCompile group: 'org.junit.jupiter', name: 'junit-jupiter', version: '5.8.0'
}
dependencies {
testCompile("org.junit.jupiter:junit-jupiter:5.8.0")
}
For TestNG:
GROOVY
KOTLIN
dependencies {
testCompile group: 'org.testng', name: 'testng', version: '7.8.0'
}
dependencies {
testCompile("org.testng:testng:7.8.0")
}
Choose one of the new test classes in the project explorer, right-click and select
'Run ClassnameTest'.The IDE will then show the results of the JUnit run.
Last modified 3mo ago

