Skip to content

Running Robolectric SNAPSHOT

utzcoz edited this page Jan 8, 2022 · 14 revisions
  1. Clone the robolectric repository: git clone --recurse-submodules https://github.com/robolectric/robolectric.
  2. Check out the branch/commit that you want to run.
  3. Run sudo apt install cmake ninja if you use Ubuntu or brew install cmake ninja if you use macOS to install build-tools used by Robolectric nativeruntime.
  4. Run ./gradlew publishMavenJavaPublicationToMavenLocal in the Robolectric root directory. It is also faster to run SKIP_JAVADOC=true ./gradlew publishMavenJavaPublicationToMavenLocal. If nativeruntime building failed on macOS/Linux with error "missing JAVA_INCLUDE...", you can check Building failed on macOS with M1 chipset for a workaround.
  5. Add mavenLocal() to your project's root project build.gradle:
    allprojects {
      repositories {
        mavenCentral()
        google()
        mavenLocal()
      }
    }
  6. Update your project to use the SNAPSHOT version of Roblectric (4.8-SNAPSHOT at time of writing).
    dependencies {
        ...
        testImplementation 'org.robolectric:robolectric:4.8-SNAPSHOT'
        ...
    }
  7. Run your project's tests.