Gradle
Dependencies
- Ubuntu / Debian
- Arch
- macOS
- Windows
sudo apt install default-jdk gradle
sudo pacman -S jdk-openjdk gradle
brew install openjdk gradle
choco install microsoft-openjdk gradle
Version requirements
Android limitations
Android fuzz tests running in an emulator or on a device aren't supported, but it's still possible to run local tests. This requires the following prerequisites:
- Gradle >= 7.5
- Android Gradle Plugin >= 7.4.2
Initialize a project
Initialize CI Fuzz in the root directory of your Gradle project with the following command:
cifuzz init
Enable CI repository access
To use CI Fuzz and its dependencies, you have to configure access to the CI repository. Your username and private token are available on your CI Download Portal Configuration page.
gradle.properties
Add the following repository credentials to your ~/.gradle/gradle.properties
file:
CodeIntelligenceRepositoryUsername=<YOUR_USERNAME>
CodeIntelligenceRepositoryPassword=<YOUR_TOKEN>
settings.gradle
To be able to access the plugin, add the CI repository as a plugin repository to your project settings:
- Groovy
- Kotlin
pluginManagement {
repositories {
maven {
name "CodeIntelligenceRepository"
url "https://gitlab.code-intelligence.com/api/v4/projects/89/packages/maven"
credentials {
username CodeIntelligenceRepositoryUsername
password CodeIntelligenceRepositoryPassword
}
content {
includeGroupByRegex("com\\.code-intelligence.*")
}
}
gradlePluginPortal()
}
}
pluginManagement {
repositories {
maven {
name = "CodeIntelligenceRepository"
url = uri("https://gitlab.code-intelligence.com/api/v4/projects/89/packages/maven")
credentials {
username = extra["CodeIntelligenceRepositoryUsername"].toString()
password = extra["CodeIntelligenceRepositoryPassword"].toString()
}
content {
includeGroupByRegex("com\\.code-intelligence.*")
}
}
gradlePluginPortal()
}
}
build.gradle
To resolve CI Fuzz dependencies, also add the CI repository in your projects build file:
- Groovy
- Kotlin
repositories {
maven {
name "CodeIntelligenceRepository"
url "https://gitlab.code-intelligence.com/api/v4/projects/89/packages/maven"
credentials {
username CodeIntelligenceRepositoryUsername
password CodeIntelligenceRepositoryPassword
}
content {
includeGroupByRegex("com\\.code-intelligence.*")
}
}
mavenCentral()
}
repositories {
maven {
name = "CodeIntelligenceRepository"
url = uri("https://gitlab.code-intelligence.com/api/v4/projects/89/packages/maven")
credentials {
username = extra["CodeIntelligenceRepositoryUsername"].toString()
password = extra["CodeIntelligenceRepositoryPassword"].toString()
}
content {
includeGroupByRegex("com\\.code-intelligence.*")
}
}
mavenCentral()
}
Add Gradle plugin
Add the CI Fuzz Gradle plugin to your projects build file to enable fuzz testing:
- Groovy
- Kotlin
plugins {
id "com.code-intelligence.cifuzz" version "1.17.0"
}
plugins {
id("com.code-intelligence.cifuzz") version "1.17.0"
}
JUnit
Fuzz tests are executed with JUnit 5. If it's not already set up, the plugin automatically adds the required dependencies and configuration to your project. If you are using JUnit 4, be aware that CI Fuzz requires the JUnit Vintage engine to run both JUnit 4 and JUnit 5 tests in one project. See the official JUnit documentation for more information.