From 1a78153b40ec918cbc1f24433135a47df74c41c0 Mon Sep 17 00:00:00 2001 From: Aitorbp Date: Fri, 26 Apr 2024 08:46:39 +0100 Subject: [PATCH] feat: added rule flaky tests to SettingsFragmentTest and LoginActivityTest --- .../android/authentication/LoginActivityTest.kt | 6 ++++++ .../android/settings/SettingsFragmentTest.kt | 12 +++++++++--- .../android/utils/RetryFlakyTestUntilSuccessRule.kt | 2 +- 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/owncloudApp/src/androidTest/java/com/owncloud/android/authentication/LoginActivityTest.kt b/owncloudApp/src/androidTest/java/com/owncloud/android/authentication/LoginActivityTest.kt index 40d91c5dcf3..d7026bd265f 100644 --- a/owncloudApp/src/androidTest/java/com/owncloud/android/authentication/LoginActivityTest.kt +++ b/owncloudApp/src/androidTest/java/com/owncloud/android/authentication/LoginActivityTest.kt @@ -77,6 +77,7 @@ import com.owncloud.android.testutil.OC_SECURE_SERVER_INFO_BEARER_AUTH import com.owncloud.android.utils.CONFIGURATION_SERVER_URL import com.owncloud.android.utils.CONFIGURATION_SERVER_URL_INPUT_VISIBILITY import com.owncloud.android.utils.NO_MDM_RESTRICTION_YET +import com.owncloud.android.utils.RetryFlakyTestUntilSuccessRule import com.owncloud.android.utils.matchers.assertVisibility import com.owncloud.android.utils.matchers.isDisplayed import com.owncloud.android.utils.matchers.isEnabled @@ -95,6 +96,7 @@ import org.junit.After import org.junit.Assert.assertEquals import org.junit.Assert.assertNotNull import org.junit.Before +import org.junit.Rule import org.junit.Test import org.koin.androidx.viewmodel.dsl.viewModel import org.koin.core.context.startKoin @@ -118,6 +120,10 @@ class LoginActivityTest { private lateinit var baseUrlLiveData: MutableLiveData>> private lateinit var accountDiscoveryLiveData: MutableLiveData>> + @Rule + @JvmField + val retryFlakyTestUntilSuccessRule = RetryFlakyTestUntilSuccessRule() + @Before fun setUp() { context = ApplicationProvider.getApplicationContext() diff --git a/owncloudApp/src/androidTest/java/com/owncloud/android/settings/SettingsFragmentTest.kt b/owncloudApp/src/androidTest/java/com/owncloud/android/settings/SettingsFragmentTest.kt index b0dbd850555..e810a374b14 100644 --- a/owncloudApp/src/androidTest/java/com/owncloud/android/settings/SettingsFragmentTest.kt +++ b/owncloudApp/src/androidTest/java/com/owncloud/android/settings/SettingsFragmentTest.kt @@ -36,11 +36,12 @@ import androidx.test.platform.app.InstrumentationRegistry import com.owncloud.android.BuildConfig import com.owncloud.android.R import com.owncloud.android.presentation.releasenotes.ReleaseNotesActivity -import com.owncloud.android.presentation.settings.privacypolicy.PrivacyPolicyActivity -import com.owncloud.android.presentation.settings.SettingsFragment import com.owncloud.android.presentation.releasenotes.ReleaseNotesViewModel -import com.owncloud.android.presentation.settings.more.SettingsMoreViewModel +import com.owncloud.android.presentation.settings.SettingsFragment import com.owncloud.android.presentation.settings.SettingsViewModel +import com.owncloud.android.presentation.settings.more.SettingsMoreViewModel +import com.owncloud.android.presentation.settings.privacypolicy.PrivacyPolicyActivity +import com.owncloud.android.utils.RetryFlakyTestUntilSuccessRule import com.owncloud.android.utils.matchers.verifyPreference import com.owncloud.android.utils.releaseNotesList import io.mockk.every @@ -50,6 +51,7 @@ import org.junit.After import org.junit.Assert.assertEquals import org.junit.Before import org.junit.Ignore +import org.junit.Rule import org.junit.Test import org.koin.androidx.viewmodel.dsl.viewModel import org.koin.core.context.startKoin @@ -76,6 +78,10 @@ class SettingsFragmentTest { private lateinit var version: String + @Rule + @JvmField + val retryFlakyTestUntilSuccessRule = RetryFlakyTestUntilSuccessRule() + @Before fun setUp() { context = InstrumentationRegistry.getInstrumentation().targetContext diff --git a/owncloudApp/src/androidTest/java/com/owncloud/android/utils/RetryFlakyTestUntilSuccessRule.kt b/owncloudApp/src/androidTest/java/com/owncloud/android/utils/RetryFlakyTestUntilSuccessRule.kt index ae56ab5f51c..b8b4a38d2b1 100644 --- a/owncloudApp/src/androidTest/java/com/owncloud/android/utils/RetryFlakyTestUntilSuccessRule.kt +++ b/owncloudApp/src/androidTest/java/com/owncloud/android/utils/RetryFlakyTestUntilSuccessRule.kt @@ -5,7 +5,7 @@ import org.junit.rules.TestRule import org.junit.runner.Description import org.junit.runners.model.Statement -class RetryFlakyTestUntilSuccessRule(val count: Int = 3) : TestRule { +class RetryFlakyTestUntilSuccessRule(val count: Int = 10) : TestRule { companion object { private const val TAG = "RetryFlakyTestUntilSuccessRule"