Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class FullScreenComponentTest {
@get:Rule
val ruleChain: RuleChain = RuleChain
.outerRule(activityRule)
.around(RetryRule(3))
.around(RetryRule())

private val rootView
get() = isAssignableFrom(StripeComponentDialogFragmentView::class.java)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class OnrampFlowTest {
val rule = RuleChain.emptyRuleChain()
.around(composeRule)
.around(attestationFeatureFlagTestRule)
.around(RetryRule(3))
.around(RetryRule())
.around(activityRule)

private val defaultTimeout: Duration = 30.seconds
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ internal class LearnMoreActivityTest {
private val applicationContext = ApplicationProvider.getApplicationContext<Application>()

@get:Rule
val retryRule = RetryRule(3)
val retryRule = RetryRule()

@Test
fun loadsUrl() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class PaymentMethodMessagingElementTest {
val testRule: RuleChain = RuleChain.emptyRuleChain()
.around(composeTestRule)
.around(networkRule)
.around(RetryRule(5))
.around(RetryRule())
.around(AdvancedFraudSignalsTestRule())

private val getConfigRequestMatcher = composite(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,35 +1,15 @@
package com.stripe.android.testing

import android.util.Log
import leakcanary.NoLeakAssertionFailedError
import org.junit.AssumptionViolatedException
import org.junit.rules.TestRule
import org.junit.runner.Description
import org.junit.runners.model.Statement

class RetryRule(private val attempts: Int) : TestRule {
class RetryRule() : TestRule {
override fun apply(base: Statement, description: Description): Statement {
val logTag = description.className
return object : Statement() {
@Throws
override fun evaluate() {
if (BuildConfig.IS_RUNNING_IN_CI) {
for (attempt in 1..attempts) {
val isLast = attempts == attempt
runCatching {
base.evaluate()
}.onSuccess {
return
}.onFailure { error ->
if (isLast || error is AssumptionViolatedException || error is NoLeakAssertionFailedError) {
throw error
}
Log.d(logTag, "Failed attempt $attempt out of $attempts with error")
}
}
} else {
base.evaluate()
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class RadarSessionTest {
val ruleChain: RuleChain = RuleChain
.outerRule(CoroutineTestRule(testDispatcher))
.around(scenarioRule)
.around(RetryRule(3))
.around(RetryRule())

@Test
fun ensureRadarSessionsAttachHCaptchaToken(): Unit = runTest(testDispatcher) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class CardInputWidgetTest {
@get:Rule
val rule = RuleChain.emptyRuleChain()
.around(composeTestRule)
.around(RetryRule(3))
.around(RetryRule())
.around(activityRule)

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class TestRules private constructor(
}
}.let { chain ->
if (BuildConfig.IS_RUNNING_IN_CI && !BuildConfig.RUN_LATENCY_TESTS_IN_CI) {
chain.around(RetryRule(retryCount))
chain.around(RetryRule())
} else {
chain
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class TestRules private constructor(
.around(DetectLeaksAfterTestSuccess())
.around(FakeGooglePayRepositoryRule())
.around(composeTestRule)
.around(RetryRule(5))
.around(RetryRule())
.around(networkRule)
.around(terminalTestRule)
.block()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ class TapToAddActivityTest {
.around(imageLoaderTestRule)
.around(FeatureFlagTestRule(FeatureFlags.forceTapToAddWithTerminal, isEnabled = true))
.around(PaymentConfigurationTestRule(applicationContext))
.around(RetryRule(3))
.around(RetryRule())
.around(intentsRule)

private val linkHelper = TapToAddLinkTestHelper(composeTestRule, networkRule)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ internal open class BaseLpmNetworkTest(
.around(createTestActivityRule<LpmNetworkTestActivity>())
.around(IntentsRule())
.around(PaymentElementCallbackTestRule())
.around(RetryRule(attempts = 3))
.around(RetryRule())

fun test(
testType: TestType,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ internal class EmbeddedSheetActivityTest {
.outerRule(composeTestRule)
.around(networkRule)
.around(PaymentConfigurationTestRule(applicationContext))
.around(RetryRule(3))
.around(RetryRule())

@Test
fun `when launched without args should finish with error result`() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ internal class PaymentOptionsActivityTest {
.around(coroutineScopeCleanupRule)
.around(composeTestRule)
.around(networkRule)
.around(RetryRule(3))
.around(RetryRule())

@get:Rule
val viewModelStoreRule = ViewModelStoreTestRule()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ internal class PaymentSheetViewModelTest {
.around(SessionTestRule())
.around(PaymentElementCallbackTestRule())
.around(ResetMockRule(eventReporter))
.around(RetryRule(3))
.around(RetryRule())

@BeforeTest
fun setup() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ internal class VerticalModePaymentSheetActivityTest {
.around(composeTestRule)
.around(networkRule)
.around(PaymentConfigurationTestRule(applicationContext))
.around(RetryRule(3))
.around(RetryRule())

@Test
fun `Allows paying with card`() = runTest(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class SSDOcrTest {
private val testContext = InstrumentationRegistry.getInstrumentation().context

@get:Rule
val retryRule = RetryRule(3)
val retryRule = RetryRule()

@Before
fun initializeTfLite() {
Expand Down
Loading