Skip to main content

Gradle

Dependencies

sudo apt install default-jdk gradle

Version requirements

Android Limitations

Android Fuzz Tests running in an emulator or on a device are not supported, but it is still possible to run local tests. The following prerequisites are required:

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:

~/.gradle/gradle.properties
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:

settings.gradle
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()
}
}

build.gradle

To resolve CI Fuzz dependencies, also add the CI repository in your projects build file:

build.gradle
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()
}

Add Gradle Plugin

Add the CI Fuzz Gradle plugin to your projects build file to enable fuzz testing:

build.gradle
plugins {
id "com.code-intelligence.cifuzz" version "1.17.0"
}

JUnit

Fuzz tests are executed with JUnit 5. If it is not already set up, the plugin will automatically add the required dependencies and configuration to your project. If you are using JUnit 4, please be aware that you will need to use the JUnit Vintage engine to be able to run both JUnit 4 and Junit 5 tests in one project. See the official JUnit documentation for more information.

Example Projects