You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've stumbled onto weird behaviour regarding coroutineScope in instrumentation tests
I might be misunderstanding something about threads or something else, but it seems an undesired behaviour for me right now
It isn't occurring in a simple unit test (not android instrumentation nor robolectric), however
Current behaviour:
UncaughtExceptionHandler is called twice with same exception
Expected Behaviour:
UncaughtExceptionHandler is called only once per every exception
EDIT:
I just realised it doesn't even require the usage of Thread.uncaughtExceptionHandler
The exception is just thrown two times regardless of that handler presence
Code sample:
@RunWith(AndroidJUnit4::class)
class ExampleInstrumentedTest {
@Test
fun uncaughtExceptionDoubling() = runBlocking{
Thread.setDefaultUncaughtExceptionHandler { t, e ->
println("Handling stuff: $e")
}
CoroutineScope(Dispatchers.Unconfined).launch {
throw IllegalStateException("Notice me")
}.join()
}
}
Output:
--------- beginning of main
11-16 05:27:12.952 10156 7902 7918 I System.out: Handling stuff: java.lang.IllegalStateException: Notice me
11-16 05:27:12.952 10156 7902 7918 I System.out: Handling stuff: java.lang.IllegalStateException: Notice me
11-16 05:27:12.952 10156 7902 7918 I TestRunner: finished: uncaughtExceptionDoubling(com.example.doubledexceptionhandling02.ExampleInstrumentedTest)
--------- beginning of kernel
Gradle dependencies (rest is standard generated by Android studio, I can provide rest if necessary)
I've stumbled onto weird behaviour regarding coroutineScope in instrumentation tests
I might be misunderstanding something about threads or something else, but it seems an undesired behaviour for me right now
It isn't occurring in a simple unit test (not android instrumentation nor robolectric), however
Current behaviour:
Expected Behaviour:
EDIT:
I just realised it doesn't even require the usage of Thread.uncaughtExceptionHandler
The exception is just thrown two times regardless of that handler presence
Code sample:
Output:
Gradle dependencies (rest is standard generated by Android studio, I can provide rest if necessary)
Kotlin plugin version:
The text was updated successfully, but these errors were encountered: