@@ -10,10 +10,16 @@ import kotlin.test.*
1010
1111expect val emulatorHost: String
1212expect val context: Any
13- expect fun runTest (test : suspend () -> Unit )
13+ expect fun runTest (skip : Boolean = false, test : suspend () -> Unit )
14+ expect val currentPlatform: Platform
15+
16+ enum class Platform { Android , IOS , JS }
1417
1518class FirebaseAuthTest {
1619
20+ // Skip the tests on iOS simulator due keychain exceptions
21+ private val skip = currentPlatform == Platform .IOS
22+
1723 @BeforeTest
1824 fun initializeFirebase () {
1925 Firebase
@@ -35,14 +41,14 @@ class FirebaseAuthTest {
3541 }
3642
3743 @Test
38- fun testSignInWithUsernameAndPassword () = runTest {
44+ fun testSignInWithUsernameAndPassword () = runTest(skip) {
3945 val uid = getTestUid(" test@test.com" , " test123" )
4046 val result = Firebase .auth.signInWithEmailAndPassword(" test@test.com" , " test123" )
4147 assertEquals(uid, result.user!! .uid)
4248 }
4349
4450 @Test
45- fun testCreateUserWithEmailAndPassword () = runTest {
51+ fun testCreateUserWithEmailAndPassword () = runTest(skip) {
4652 val email = " test+${Random .nextInt(100000 )} @test.com"
4753 val createResult = Firebase .auth.createUserWithEmailAndPassword(email, " test123" )
4854 assertNotEquals(null , createResult.user?.uid)
@@ -57,7 +63,7 @@ class FirebaseAuthTest {
5763 }
5864
5965 @Test
60- fun testFetchSignInMethods () = runTest {
66+ fun testFetchSignInMethods () = runTest(skip) {
6167 val email = " test+${Random .nextInt(100000 )} @test.com"
6268 var signInMethodResult = Firebase .auth.fetchSignInMethodsForEmail(email)
6369 assertEquals(emptyList(), signInMethodResult)
@@ -69,7 +75,7 @@ class FirebaseAuthTest {
6975 }
7076
7177 @Test
72- fun testSendEmailVerification () = runTest {
78+ fun testSendEmailVerification () = runTest(skip) {
7379 val email = " test+${Random .nextInt(100000 )} @test.com"
7480 val createResult = Firebase .auth.createUserWithEmailAndPassword(email, " test123" )
7581 assertNotEquals(null , createResult.user?.uid)
@@ -79,7 +85,7 @@ class FirebaseAuthTest {
7985 }
8086
8187 @Test
82- fun sendPasswordResetEmail () = runTest {
88+ fun sendPasswordResetEmail () = runTest(skip) {
8389 val email = " test+${Random .nextInt(100000 )} @test.com"
8490 val createResult = Firebase .auth.createUserWithEmailAndPassword(email, " test123" )
8591 assertNotEquals(null , createResult.user?.uid)
@@ -90,7 +96,7 @@ class FirebaseAuthTest {
9096 }
9197
9298 @Test
93- fun testSignInWithCredential () = runTest {
99+ fun testSignInWithCredential () = runTest(skip) {
94100 val uid = getTestUid(" test@test.com" , " test123" )
95101 val credential = EmailAuthProvider .credential(" test@test.com" , " test123" )
96102 val result = Firebase .auth.signInWithCredential(credential)
0 commit comments