Step 1. Add the JitPack repository to your build file
Add it in your root settings.gradle at the end of repositories:
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
mavenCentral()
maven { url 'https://jitpack.io' }
}
}
Add it in your settings.gradle.kts at the end of repositories:
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
mavenCentral()
maven { url = uri("https://jitpack.io") }
}
}
Add to pom.xml
<repositories>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>
Add it in your build.sbt at the end of resolvers:
resolvers += "jitpack" at "https://jitpack.io"
Add it in your project.clj at the end of repositories:
:repositories [["jitpack" "https://jitpack.io"]]
Step 2. Add the dependency
dependencies {
implementation 'com.github.gildor:gradle-firebase-test-lab-plugin:'
}
dependencies {
implementation("com.github.gildor:gradle-firebase-test-lab-plugin:")
}
<dependency>
<groupId>com.github.gildor</groupId>
<artifactId>gradle-firebase-test-lab-plugin</artifactId>
<version></version>
</dependency>
libraryDependencies += "com.github.gildor" % "gradle-firebase-test-lab-plugin" % ""
:dependencies [[com.github.gildor/gradle-firebase-test-lab-plugin ""]]
This is experimental Gradle plugin for Firebase Test Lab
//Add dependency to your build script
buildscript {
repositories {
maven {
url "https://plugins.gradle.org/m2/"
}
}
dependencies {
classpath "gradle.plugin.ru.gildor.gradle.firebase.testlab:firebase-test-lab:0.1.1"
}
}
//Apply plugin in your target Android projet
apply plugin: 'firebase-test-lab'
//Configure plugin
firebaseTestLab {
// [REQUIRED] Path to Google Cloud SDK CLI tools - https://cloud.google.com/sdk/gcloud/
gcloudPath = "/Library/google-cloud-sdk/bin/"
// [REQUIRED] Google Cloud Storage bucket name to keep test results
bucketName = "android_ci"
// `false` by default
ignoreFailures = false
// Plugin will create tasks not only for each your build variant,
// but also without dependency on current project app build,
// this allow you to run tests with configured matrices for any pair of apk and test apk
// You must pass path to apk and testApk as gradle build parameters -Papk and -PtestApk. false by default
enableVariantLessTasks = false
// Configuration that allows to download test result artifacts to build dir
copyArtifact {
// Test results in junit XML result format. true by default
junit = true
// File with Android logs. false by default
logcat = false
// Video of test. false by default
video = false
// Test results in test lab format (plain text log file)
instrumentation = false
}
// Configuration of your matrices. Plugin creates 2 tasks for each matrix (for instrumentation and robo tests)
matrices {
// Name of matrix (test configuration)
// How to choose configuration:
// https://firebase.google.com/docs/test-lab/command-line#choosing_test_configurations
nexus7 {
// [REQUIRED] API level of devices
androidApiLevels = [19, 21]
// [REQUIRED] Names of devices.
deviceIds = ["flo"]
// Locale. "en" by default
locales = ["en"]
// Orientation of device. Can be `portrait` or `landscape`. Portrait by default
orientations = ["portrait", "landscape"]
// Maximum test length. No timeout by default
timeoutSec = 0
}
// Example of minimal matrix configuration for 1 device (Nexus 5 with API Level 21)
nexus5 {
androidApiLevels = [21]
deviceIds = ["hammerhead"]
}
}
}
Example of configuration for Gradle Script Kotlin (for version 0.7)
import ru.gildor.gradle.firebase.testlab.*
import ru.gildor.gradle.firebase.testlab.Orientation.*
apply {
plugin<FirebaseTestLabPlugin>()
}
configure<FirebaseTestLabPlugin> {
gcloudPath = "/Library/google-cloud-sdk/bin/"
bucketName = "android_ci"
ignoreFailures = true
copyArtifact {
junit = true
logcat = true
}
matrices {
"nexus7" {
androidApiLevels = listOf(19, 21)
deviceIds = listOf("flo")
locales = listOf("en")
orientations = listOf(portrait, landscape)
}
}
}
To run tests you should use one of plugin tasks
./gradlew test<BuildVariant><MatrixName><TestType>TestLab
For example:
./gradlew testDebugNexus5InstrumentationTestLab
Will be started instrumentation test for debug build (no flavor) for matrix with name nexus5