Skip to content

Commit d0e0dd2

Browse files
authored
Enable FTL tests for all projects except functions. (#300)
* Enable FTL tests for all projects except functions. * Updated readme. * Import cleanup. * Fix google-services task dep.
1 parent de350fe commit d0e0dd2

File tree

9 files changed

+40
-8
lines changed

9 files changed

+40
-8
lines changed

README.md

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,13 +89,41 @@ If you don't have a suitable testing project already:
8989
* Download the resulting `google-services.json` file and put it in the root of
9090
your checkout.
9191

92-
#### Running Integration Tests
92+
#### Running Integration Tests on Local Emulator
9393

9494
Integration tests can be executed on the command line by running
9595
```bash
9696
./gradlew :<firebase-project>:connectedCheck
9797
```
9898

99+
#### Running Integration Tests on Firebase Test Lab
100+
101+
> You need additional setup for this to work:
102+
>
103+
> * `gcloud` needs to be [installed](https://cloud.google.com/sdk/install) on local machine
104+
> * `gcloud` needs to be configured with a project that has billing enabled
105+
> * `gcloud` needs to be authenticated with credentials that have 'Firebase Test Lab Admin' role
106+
107+
Integration tests can be executed on the command line by running
108+
```bash
109+
./gradlew :<firebase-project>:deviceCheck
110+
```
111+
112+
This will execute tests on devices that are configured per project, if nothing is configured for the
113+
project, the tests will run on `model=Pixel2,version=27,locale=en,orientation=portrait`.
114+
115+
Projects can be configured in the following way:
116+
117+
```
118+
firebaseTestLab {
119+
// to get a list of available devices execute `gcloud firebase test android models list`
120+
devices = [
121+
'<device1>',
122+
'<device2>',
123+
]
124+
}
125+
```
126+
99127
## Annotations
100128

101129
Firebase SDKs use some special annotations for tooling purposes.

buildSrc/src/main/groovy/com/google/firebase/gradle/plugins/ci/device/FirebaseTestLabPlugin.groovy

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,13 @@
1414

1515
package com.google.firebase.gradle.plugins.ci.device
1616

17-
import com.android.build.gradle.LibraryExtension
1817
import org.gradle.api.Plugin
19-
import org.gradle.api.Project;
18+
import org.gradle.api.Project
2019

2120
class FirebaseTestLabPlugin implements Plugin<Project>{
2221
@Override
2322
void apply(Project project) {
2423
def extension = project.extensions.create('firebaseTestLab', FirebaseTestLabExtension.class)
25-
LibraryExtension e = project.android
26-
e.testServer(new FirebaseTestServer(project, extension))
24+
project.android.testServer(new FirebaseTestServer(project, extension))
2725
}
2826
}

fiamui-app/fiamui-app.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
// limitations under the License.
1414

1515
apply plugin: "com.android.application"
16+
apply plugin: com.google.firebase.gradle.plugins.ci.device.FirebaseTestLabPlugin
1617

1718
android {
1819
compileSdkVersion project.targetSdkVersion

firebase-common/firebase-common.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
// limitations under the License.
1414

1515
apply plugin: 'com.android.library'
16+
apply plugin: com.google.firebase.gradle.plugins.ci.device.FirebaseTestLabPlugin
1617

1718
android {
1819
adbOptions {

firebase-database/firebase-database.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
// limitations under the License.
1414

1515
apply plugin: 'com.android.library'
16+
apply plugin: com.google.firebase.gradle.plugins.ci.device.FirebaseTestLabPlugin
1617

1718
android {
1819
adbOptions {

firebase-firestore/firebase-firestore.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
apply plugin: 'com.android.library'
1616
apply plugin: 'com.google.protobuf'
17+
apply plugin: com.google.firebase.gradle.plugins.ci.device.FirebaseTestLabPlugin
1718

1819
protobuf {
1920
// Configure the protoc executable

firebase-inappmessaging-display/firebase-inappmessaging-display.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
// limitations under the License.
1414

1515
apply plugin: "com.android.library"
16+
apply plugin: com.google.firebase.gradle.plugins.ci.device.FirebaseTestLabPlugin
1617

1718
android {
1819
compileSdkVersion project.targetSdkVersion

firebase-storage/firebase-storage.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
// limitations under the License.
1414

1515
apply plugin: 'com.android.library'
16+
apply plugin: com.google.firebase.gradle.plugins.ci.device.FirebaseTestLabPlugin
1617

1718
android {
1819
adbOptions {

gradle/googleServices.gradle

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,11 @@ afterEvaluate {
4444
// somewhere in the task graph (for instance if you ran
4545
// ./gradlew test at the root project).
4646
def isTesting = getGradle().getStartParameter().getTaskNames().any({ String taskName ->
47-
def hasProjectTestTask = taskName.contains("$name") && ['AndroidTest', 'connectedCheck'].any({ taskName.contains(it)})
48-
return hasProjectTestTask || taskName.contains('connectedCheck')
47+
def hasProjectTestTask = taskName.contains("$name") && ['AndroidTest', 'connectedCheck', 'deviceCheck'].any({ taskName.contains(it)})
48+
return hasProjectTestTask || taskName.contains('connectedCheck') || taskName.contains('deviceCheck')
4949
})
5050

5151
if (isTesting) {
5252
println '[test] applying google-services plugin'
5353
apply plugin: 'com.google.gms.google-services'
54-
}
54+
}

0 commit comments

Comments
 (0)