Skip to content

Commit 4d7d362

Browse files
committed
Use test app for Sessions e2e test
1 parent 188f623 commit 4d7d362

File tree

3 files changed

+61
-3
lines changed

3 files changed

+61
-3
lines changed

.github/workflows/sessions-e2e.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,15 @@ env:
1212
SESSIONS_E2E_GOOGLE_SERVICES: ${{ secrets.SESSIONS_E2E_GOOGLE_SERVICES }}
1313

1414
jobs:
15-
build:
15+
test:
1616

1717
runs-on: ubuntu-latest
1818

1919
steps:
2020
- name: Checkout firebase-sessions
2121
uses: actions/checkout@v3
2222
with:
23-
ref: 'firebase-sessions'
23+
ref: 'sessions-apptest'
2424

2525
- name: set up JDK 11
2626
uses: actions/setup-java@v3
@@ -42,4 +42,4 @@ jobs:
4242
FTL_RESULTS_BUCKET: fireescape
4343
FIREBASE_APP_CHECK_DEBUG_SECRET: ${{ secrets.FIREBASE_APP_CHECK_DEBUG_SECRET }}
4444
run: |
45-
./gradlew :firebase-sessions:deviceCheck withErrorProne -PtargetBackend="prod"
45+
./gradlew :firebase-sessions:test-app:deviceCheck withErrorProne -PtargetBackend="prod"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
/*
2+
* Copyright 2023 Google LLC
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package com.google.firebase.testing.sessions
18+
19+
import androidx.test.core.app.ApplicationProvider
20+
import androidx.test.ext.junit.runners.AndroidJUnit4
21+
import com.google.common.truth.Truth.assertThat
22+
import com.google.firebase.FirebaseApp
23+
import com.google.firebase.ktx.Firebase
24+
import com.google.firebase.ktx.initialize
25+
import com.google.firebase.sessions.FirebaseSessions
26+
import org.junit.After
27+
import org.junit.Before
28+
import org.junit.Test
29+
import org.junit.runner.RunWith
30+
31+
@RunWith(AndroidJUnit4::class)
32+
class FirebaseSessionsTest {
33+
@Before
34+
fun setUp() {
35+
Firebase.initialize(ApplicationProvider.getApplicationContext())
36+
}
37+
38+
@After
39+
fun cleanUp() {
40+
FirebaseApp.clearInstancesForTest()
41+
}
42+
43+
@Test
44+
fun initializeSession() {
45+
// Force the Firebase Sessions SDK to initialize.
46+
assertThat(FirebaseSessions.instance.greeting()).isEqualTo("Matt says hi!")
47+
48+
// Wait for the session start event to send.
49+
// TODO(mrober): Setup logger we can access from tests.
50+
Thread.sleep(40_000)
51+
}
52+
}

firebase-sessions/test-app/test-app.gradle.kts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ android {
3030
versionCode = 1
3131
versionName = "1.0"
3232
multiDexEnabled = true
33+
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
3334
}
3435
compileOptions {
3536
sourceCompatibility = JavaVersion.VERSION_1_8
@@ -46,6 +47,11 @@ dependencies {
4647
implementation("androidx.constraintlayout:constraintlayout:2.1.4")
4748
implementation("androidx.core:core-ktx:1.9.0")
4849
implementation("com.google.android.material:material:1.8.0")
50+
51+
androidTestImplementation("com.google.firebase:firebase-common-ktx:20.3.2")
52+
androidTestImplementation(libs.androidx.test.junit)
53+
androidTestImplementation(libs.androidx.test.runner)
54+
androidTestImplementation(libs.truth)
4955
}
5056

5157
extra["packageName"] = "com.google.firebase.testing.sessions"

0 commit comments

Comments
 (0)