-
Notifications
You must be signed in to change notification settings - Fork 625
Use test app for Sessions e2e test #4881
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
/* | ||
* Copyright 2023 Google LLC | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.google.firebase.testing.sessions | ||
|
||
import androidx.test.core.app.ApplicationProvider | ||
import androidx.test.ext.junit.runners.AndroidJUnit4 | ||
import com.google.common.truth.Truth.assertThat | ||
import com.google.firebase.FirebaseApp | ||
import com.google.firebase.ktx.Firebase | ||
import com.google.firebase.ktx.initialize | ||
import com.google.firebase.sessions.FirebaseSessions | ||
import org.junit.After | ||
import org.junit.Before | ||
import org.junit.Test | ||
import org.junit.runner.RunWith | ||
|
||
@RunWith(AndroidJUnit4::class) | ||
class FirebaseSessionsTest { | ||
@Before | ||
fun setUp() { | ||
Firebase.initialize(ApplicationProvider.getApplicationContext()) | ||
} | ||
|
||
@After | ||
fun cleanUp() { | ||
FirebaseApp.clearInstancesForTest() | ||
} | ||
|
||
@Test | ||
fun initializeSession() { | ||
// Force the Firebase Sessions SDK to initialize. | ||
assertThat(FirebaseSessions.instance.greeting()).isEqualTo("Matt says hi!") | ||
|
||
// Wait for the session start event to send. | ||
// TODO(mrober): Setup logger we can access from tests. | ||
Thread.sleep(TIME_TO_LOG_SESSION) | ||
} | ||
|
||
companion object { | ||
private const val TIME_TO_LOG_SESSION = 60_000L | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,7 @@ | ||
@file:Suppress("DEPRECATION") // App projects should still use FirebaseTestLabPlugin. | ||
|
||
import com.google.firebase.gradle.plugins.ci.device.FirebaseTestLabPlugin | ||
|
||
/* | ||
* Copyright 2023 Google LLC | ||
* | ||
|
@@ -30,6 +34,7 @@ android { | |
versionCode = 1 | ||
versionName = "1.0" | ||
multiDexEnabled = true | ||
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" | ||
} | ||
compileOptions { | ||
sourceCompatibility = JavaVersion.VERSION_1_8 | ||
|
@@ -46,8 +51,15 @@ dependencies { | |
implementation("androidx.constraintlayout:constraintlayout:2.1.4") | ||
implementation("androidx.core:core-ktx:1.9.0") | ||
implementation("com.google.android.material:material:1.8.0") | ||
|
||
androidTestImplementation("com.google.firebase:firebase-common-ktx:20.3.2") | ||
androidTestImplementation(libs.androidx.test.junit) | ||
androidTestImplementation(libs.androidx.test.runner) | ||
androidTestImplementation(libs.truth) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why do we need this dependency? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I prefer using Guava's Truth than JUnit's regular asserts. Truth reads much better, and other Firebase SDKs use it in their tests too. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. My comment was in the context of why we use that for the test app. For SDK's it makes sense to me. Do we have tests for the test app and we are using Guava's truth library for that? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh is there any reason we should avoid it? Right now we do 1 |
||
} | ||
|
||
extra["packageName"] = "com.google.firebase.testing.sessions" | ||
|
||
apply(from = "../../gradle/googleServices.gradle") | ||
|
||
apply<FirebaseTestLabPlugin>() |
Uh oh!
There was an error while loading. Please reload this page.