Skip to content

Commit

Permalink
feat: added rule flaky tests to SettingsFragmentTest and LoginActivit…
Browse files Browse the repository at this point in the history
…yTest
  • Loading branch information
Aitorbp committed Apr 26, 2024
1 parent d8dce5c commit 1a78153
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -118,6 +120,10 @@ class LoginActivityTest {
private lateinit var baseUrlLiveData: MutableLiveData<Event<UIResult<String>>>
private lateinit var accountDiscoveryLiveData: MutableLiveData<Event<UIResult<Unit>>>

@Rule
@JvmField
val retryFlakyTestUntilSuccessRule = RetryFlakyTestUntilSuccessRule()

@Before
fun setUp() {
context = ApplicationProvider.getApplicationContext()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -76,6 +78,10 @@ class SettingsFragmentTest {

private lateinit var version: String

@Rule
@JvmField
val retryFlakyTestUntilSuccessRule = RetryFlakyTestUntilSuccessRule()

@Before
fun setUp() {
context = InstrumentationRegistry.getInstrumentation().targetContext
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit 1a78153

Please sign in to comment.