Skip to content

Commit ff8e241

Browse files
committed
RUM-10417: Fix the unit test
1 parent a08f258 commit ff8e241

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

integrations/dd-sdk-android-okhttp/src/test/kotlin/com/datadog/android/okhttp/trace/TracingInterceptorTest.kt

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1660,7 +1660,7 @@ internal open class TracingInterceptorTest {
16601660
}
16611661

16621662
@Test
1663-
fun `M log error W listener causes StackOverflowError through infinite recursion`(
1663+
fun `M log error and rethrow W listener causes StackOverflowError`(
16641664
@IntForgery(min = 200, max = 600) statusCode: Int
16651665
) {
16661666
// Given
@@ -1669,13 +1669,12 @@ internal open class TracingInterceptorTest {
16691669

16701670
whenever(
16711671
mockRequestListener.onRequestIntercepted(any(), any(), anyOrNull(), anyOrNull())
1672-
).doAnswer {
1673-
testedInterceptor.intercept(mockChain)
1674-
return@doAnswer Unit
1675-
}
1672+
).doAnswer { throw StackOverflowError() }
16761673

16771674
// When
1678-
testedInterceptor.intercept(mockChain)
1675+
assertThrows<StackOverflowError> {
1676+
testedInterceptor.intercept(mockChain)
1677+
}
16791678

16801679
// Then
16811680
val expectedMessage = "${TracingInterceptor.ERROR_STACK_OVERFLOW}\n" +
@@ -1685,7 +1684,8 @@ internal open class TracingInterceptorTest {
16851684
InternalLogger.Level.ERROR,
16861685
InternalLogger.Target.USER,
16871686
expectedMessage,
1688-
StackOverflowError::class.java
1687+
StackOverflowError::class.java,
1688+
mode = org.mockito.kotlin.atLeast(1)
16891689
)
16901690
}
16911691

0 commit comments

Comments
 (0)