Skip to content

Instantly share code, notes, and snippets.

@sembozdemir
Last active September 15, 2023 15:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sembozdemir/6341312d9528c5b3d6a4b5907d5caa18 to your computer and use it in GitHub Desktop.
Save sembozdemir/6341312d9528c5b3d6a4b5907d5caa18 to your computer and use it in GitHub Desktop.
Fix for Robolectric and Bitrise issue
# ignore Robolectric jar dependencies
#Robolectric jars for unit tests
/robolectric/*.jar
// add this line into your root build.gradle
// and make sure to run `fetchRobolectricDependencies` gradle task before running your tests
// e.g. `./gradlew fetchRobolectricDependencies test`
apply from: "$rootDir/robolectric.gradle"
// add this file into your root directory
configurations {
robo32Instrumented
robo33Instrumented
}
dependencies {
robo32Instrumented "org.robolectric:android-all-instrumented:12.1-robolectric-8229987-i4"
robo33Instrumented "org.robolectric:android-all-instrumented:13-robolectric-9030017-i4"
}
def robolectricDependencies = "$rootDir/robolectric"
tasks.register('fetchRobolectricDependencies', Copy) {
from configurations.robo32Instrumented
from configurations.robo33Instrumented
into robolectricDependencies
}
subprojects {
afterEvaluate {
if (project.plugins.hasPlugin("com.android.application") || project.plugins.hasPlugin("com.android.library")) {
android {
testOptions.unitTests.all {
systemProperty 'robolectric.offline', 'true'
systemProperty 'robolectric.dependency.dir', robolectricDependencies
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment