Skip to content

Commit 54284f9

Browse files
committed
Adjusted tests to not use skip variable.
Added granular ios test skip
1 parent f76978b commit 54284f9

File tree

10 files changed

+24
-36
lines changed

10 files changed

+24
-36
lines changed

firebase-app/build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ kotlin {
5858
}
5959

6060
val supportIosTarget = project.property("skipIosTarget") != "true"
61-
val runIosTests = project.property("skipIosTests") != "true"
61+
val runIosTests = project.property("firebase-app.skipIosTests") != "true"
6262

6363
if (supportIosTarget) {
6464

firebase-auth/src/commonTest/kotlin/dev/gitlive/firebase/auth/auth.kt

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,10 @@ import kotlin.test.*
1010

1111
expect val emulatorHost: String
1212
expect val context: Any
13-
expect fun runTest(skip: Boolean = false, test: suspend () -> Unit)
14-
expect val currentPlatform: Platform
15-
16-
enum class Platform { Android, IOS, JS }
13+
expect fun runTest(test: suspend () -> Unit)
1714

1815
class FirebaseAuthTest {
1916

20-
// Skip the tests on iOS simulator due keychain exceptions
21-
private val skip = currentPlatform == Platform.IOS
22-
2317
@BeforeTest
2418
fun initializeFirebase() {
2519
Firebase
@@ -41,14 +35,14 @@ class FirebaseAuthTest {
4135
}
4236

4337
@Test
44-
fun testSignInWithUsernameAndPassword() = runTest(skip) {
38+
fun testSignInWithUsernameAndPassword() = runTest {
4539
val uid = getTestUid("[email protected]", "test123")
4640
val result = Firebase.auth.signInWithEmailAndPassword("[email protected]", "test123")
4741
assertEquals(uid, result.user!!.uid)
4842
}
4943

5044
@Test
51-
fun testCreateUserWithEmailAndPassword() = runTest(skip) {
45+
fun testCreateUserWithEmailAndPassword() = runTest {
5246
val email = "test+${Random.nextInt(100000)}@test.com"
5347
val createResult = Firebase.auth.createUserWithEmailAndPassword(email, "test123")
5448
assertNotEquals(null, createResult.user?.uid)
@@ -63,7 +57,7 @@ class FirebaseAuthTest {
6357
}
6458

6559
@Test
66-
fun testFetchSignInMethods() = runTest(skip) {
60+
fun testFetchSignInMethods() = runTest {
6761
val email = "test+${Random.nextInt(100000)}@test.com"
6862
var signInMethodResult = Firebase.auth.fetchSignInMethodsForEmail(email)
6963
assertEquals(emptyList(), signInMethodResult)
@@ -75,7 +69,7 @@ class FirebaseAuthTest {
7569
}
7670

7771
@Test
78-
fun testSendEmailVerification() = runTest(skip) {
72+
fun testSendEmailVerification() = runTest {
7973
val email = "test+${Random.nextInt(100000)}@test.com"
8074
val createResult = Firebase.auth.createUserWithEmailAndPassword(email, "test123")
8175
assertNotEquals(null, createResult.user?.uid)
@@ -85,7 +79,7 @@ class FirebaseAuthTest {
8579
}
8680

8781
@Test
88-
fun sendPasswordResetEmail() = runTest(skip) {
82+
fun sendPasswordResetEmail() = runTest {
8983
val email = "test+${Random.nextInt(100000)}@test.com"
9084
val createResult = Firebase.auth.createUserWithEmailAndPassword(email, "test123")
9185
assertNotEquals(null, createResult.user?.uid)
@@ -96,7 +90,7 @@ class FirebaseAuthTest {
9690
}
9791

9892
@Test
99-
fun testSignInWithCredential() = runTest(skip) {
93+
fun testSignInWithCredential() = runTest {
10094
val uid = getTestUid("[email protected]", "test123")
10195
val credential = EmailAuthProvider.credential("[email protected]", "test123")
10296
val result = Firebase.auth.signInWithCredential(credential)

firebase-auth/src/iosTest/kotlin/dev/gitlive/firebase/auth/auth.kt

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,7 @@ actual val emulatorHost: String = "localhost"
1111

1212
actual val context: Any = Unit
1313

14-
actual val currentPlatform: Platform = Platform.IOS
15-
16-
actual fun runTest(skip: Boolean, test: suspend () -> Unit) = runBlocking {
17-
if (skip) {
18-
NSLog("Skip the test.")
19-
return@runBlocking
20-
}
21-
14+
actual fun runTest(test: suspend () -> Unit) = runBlocking {
2215
val testRun = MainScope().async { test() }
2316
while (testRun.isActive) {
2417
NSRunLoop.mainRunLoop.runMode(

firebase-auth/src/jsTest/kotlin/dev/gitlive/firebase/auth/auth.kt

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,8 @@ actual val emulatorHost: String = "localhost"
1111

1212
actual val context: Any = Unit
1313

14-
actual val currentPlatform: Platform = Platform.JS
15-
16-
actual fun runTest(skip: Boolean, test: suspend () -> Unit) = GlobalScope
14+
actual fun runTest(test: suspend () -> Unit) = GlobalScope
1715
.promise {
18-
if (skip) {
19-
console.log("Skip the test.")
20-
return@promise
21-
}
22-
2316
try {
2417
test()
2518
} catch (e: dynamic) {

firebase-common/build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ kotlin {
4747
}
4848

4949
val supportIosTarget = project.property("skipIosTarget") != "true"
50-
val runIosTests = project.property("skipIosTests") != "true"
50+
val runIosTests = project.property("firebase-common.skipIosTests") != "true"
5151

5252
if (supportIosTarget) {
5353
ios()

firebase-config/build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ kotlin {
7070
}
7171

7272
val supportIosTarget = project.property("skipIosTarget") != "true"
73-
val runIosTests = project.property("skipIosTests") != "true"
73+
val runIosTests = project.property("firebase-config.skipIosTests") != "true"
7474

7575
if (supportIosTarget) {
7676
fun nativeTargetConfig(): KotlinNativeTarget.() -> Unit = {

firebase-database/build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ kotlin {
5757
}
5858

5959
val supportIosTarget = project.property("skipIosTarget") != "true"
60-
val runIosTests = project.property("skipIosTests") != "true"
60+
val runIosTests = project.property("firebase-database.skipIosTests") != "true"
6161

6262
if (supportIosTarget) {
6363
fun nativeTargetConfig(): KotlinNativeTarget.() -> Unit = {

firebase-firestore/build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ kotlin {
6060
}
6161

6262
val supportIosTarget = project.property("skipIosTarget") != "true"
63-
val runIosTests = project.property("skipIosTests") != "true"
63+
val runIosTests = project.property("firebase-firestore.skipIosTests") != "true"
6464

6565
if (supportIosTarget) {
6666
fun nativeTargetConfig(): KotlinNativeTarget.() -> Unit = {

firebase-functions/build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ kotlin {
5252
}
5353

5454
val supportIosTarget = project.property("skipIosTarget") != "true"
55-
val runIosTests = project.property("skipIosTests") != "true"
55+
val runIosTests = project.property("firebase-functions.skipIosTests") != "true"
5656

5757
if (supportIosTarget) {
5858
fun nativeTargetConfig(): KotlinNativeTarget.() -> Unit = {

gradle.properties

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,16 @@ org.gradle.parallel=true
1717
systemProp.org.gradle.internal.publish.checksums.insecure=true
1818
testOptions.unitTests.isIncludeAndroidResources=true
1919

20+
# Set to true to skip tests and even compilation of the iOS target.
2021
skipIosTarget=false
21-
skipIosTests=false
22+
# Skip iOS Tests
23+
firebase-app.skipIosTests=false
24+
firebase-auth.skipIosTests=false
25+
firebase-common.skipIosTests=false
26+
firebase-database.skipIosTests=false
27+
firebase-firestore.skipIosTests=false
28+
firebase-functions.skipIosTests=false
29+
firebase-config.skipIosTests=false
2230

2331
# Versions:
2432
firebase-app.version=1.4.2

0 commit comments

Comments
 (0)