- Tests updated and yml updated

Took 1 hour 2 minutes
This commit is contained in:
2023-03-15 16:23:54 +00:00
parent b897ed9b61
commit 8503d0d2b5
4 changed files with 52 additions and 15 deletions

View File

@@ -60,7 +60,8 @@ open class FirebaseTest<T : BaseActivity<*>>(
// remove the user we created for testing
suspend fun removeUser() {
firebaseAuthSource.getUser()?.email?.let {
getEmail()?.let {
if (firebaseAuthSource.getUser() == null) firebaseAuthSource.signIn(email = it, password = USER_PASSWORD).await()
firebaseAuthSource.reauthenticate(it, USER_PASSWORD).await()
firebaseAuthSource.deleteProfile().await()
}
@@ -68,7 +69,8 @@ open class FirebaseTest<T : BaseActivity<*>>(
fun generateEmailAddress(): String {
val suffix = (1000..50000).random()
return "test-${suffix}@test-account.com"
email ="test-${suffix}@test-account.com"
return email!!
}
fun getEmail(): String? {

View File

@@ -0,0 +1,38 @@
package h_mal.appttude.com.tests
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.LargeTest
import h_mal.appttude.com.FirebaseTest
import h_mal.appttude.com.R
import h_mal.appttude.com.USER_PASSWORD
import h_mal.appttude.com.robots.home
import h_mal.appttude.com.robots.login
import h_mal.appttude.com.robots.register
import h_mal.appttude.com.ui.user.LoginActivity
import org.junit.*
import org.junit.runner.RunWith
@LargeTest
@RunWith(AndroidJUnit4::class)
class RegisteredUserAuthenticationActivityTest : FirebaseTest<LoginActivity>(LoginActivity::class.java, registered = true, signedIn = false) {
@Before
fun waitForSplashScreen() {
waitFor(100)
}
@Test
fun verifyUserLogin_validUsernameAndPassword_loggedIn() {
login {
println("lets get the email = ${getEmail()}")
setEmail(getEmail())
setPassword(USER_PASSWORD)
clickLogin()
}
home {
checkTitleExists(getResourceString(R.string.welcome_title))
}
}
}

View File

@@ -16,7 +16,7 @@ import org.junit.runner.RunWith
@LargeTest
@RunWith(AndroidJUnit4::class)
class UserAuthenticationActivityTest : FirebaseTest<LoginActivity>(LoginActivity::class.java, registered = true, signedIn = false) {
class UserAuthenticationActivityTest : FirebaseTest<LoginActivity>(LoginActivity::class.java) {
@Before
fun waitForSplashScreen() {
@@ -40,16 +40,4 @@ class UserAuthenticationActivityTest : FirebaseTest<LoginActivity>(LoginActivity
}
}
@Test
fun verifyUserLogin_validUsernameAndPassword_loggedIn() {
login {
println("lets get the email = ${getEmail()}")
setEmail(getEmail())
setPassword(USER_PASSWORD)
clickLogin()
}
home {
checkTitleExists(getResourceString(R.string.welcome_title))
}
}
}