diff --git a/.circleci/config.yml b/.circleci/config.yml index f8bcc8a..91b4f01 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -62,6 +62,15 @@ jobs: - store_artifacts: path: app/build/reports/androidTests/connected destination: reports + # Then publish the artifacts of the Firebase emulator logs! + - run: + name: save firebase emulator logs + command: | + mkdir -p /tmp/firebase_logs + cp *.log /tmp/firebase_logs + - store_artifacts: + path: /tmp/firebase_logs + destination: logs # Then publish the results of the Instrumentation tests! - store_test_results: path: app/build/outputs/androidTest-results/connected diff --git a/app/src/androidTest/java/h_mal/appttude/com/FirebaseTest.kt b/app/src/androidTest/java/h_mal/appttude/com/FirebaseTest.kt index 4c5ee65..793bcc8 100644 --- a/app/src/androidTest/java/h_mal/appttude/com/FirebaseTest.kt +++ b/app/src/androidTest/java/h_mal/appttude/com/FirebaseTest.kt @@ -60,7 +60,8 @@ open class FirebaseTest>( // 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>( 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? { diff --git a/app/src/androidTestDriver/java/h_mal/appttude/com/tests/RegisteredUserAuthenticationActivityTest.kt b/app/src/androidTestDriver/java/h_mal/appttude/com/tests/RegisteredUserAuthenticationActivityTest.kt new file mode 100644 index 0000000..4b77a23 --- /dev/null +++ b/app/src/androidTestDriver/java/h_mal/appttude/com/tests/RegisteredUserAuthenticationActivityTest.kt @@ -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::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)) + } + } +} diff --git a/app/src/androidTestDriver/java/h_mal/appttude/com/tests/UserAuthenticationActivityTest.kt b/app/src/androidTestDriver/java/h_mal/appttude/com/tests/UserAuthenticationActivityTest.kt index fa1759d..ddc7d76 100644 --- a/app/src/androidTestDriver/java/h_mal/appttude/com/tests/UserAuthenticationActivityTest.kt +++ b/app/src/androidTestDriver/java/h_mal/appttude/com/tests/UserAuthenticationActivityTest.kt @@ -16,7 +16,7 @@ import org.junit.runner.RunWith @LargeTest @RunWith(AndroidJUnit4::class) -class UserAuthenticationActivityTest : FirebaseTest(LoginActivity::class.java, registered = true, signedIn = false) { +class UserAuthenticationActivityTest : FirebaseTest(LoginActivity::class.java) { @Before fun waitForSplashScreen() { @@ -40,16 +40,4 @@ class UserAuthenticationActivityTest : FirebaseTest(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)) - } - } }