File tree Expand file tree Collapse file tree 1 file changed +17
-3
lines changed
tests/testutils/src/main/kotlin/io/element/android/tests/testutils Expand file tree Collapse file tree 1 file changed +17
-3
lines changed Original file line number Diff line number Diff line change @@ -12,14 +12,28 @@ import app.cash.molecule.moleculeFlow
1212import app.cash.turbine.TurbineTestContext
1313import app.cash.turbine.test
1414import io.element.android.libraries.architecture.Presenter
15+ import org.junit.Assert.fail
1516import kotlin.time.Duration
1617
1718suspend fun <State > Presenter<State>.test (
1819 timeout : Duration ? = null,
1920 name : String? = null,
2021 validate : suspend TurbineTestContext <State >.() -> Unit ,
2122) {
22- moleculeFlow(RecompositionMode .Immediate ) {
23- present()
24- }.test(timeout, name, validate)
23+ try {
24+ moleculeFlow(RecompositionMode .Immediate ) {
25+ present()
26+ }.test(timeout, name, validate)
27+ } catch (t: Throwable ) {
28+ if (t::class .simpleName == " KotlinReflectionInternalError" ) {
29+ // Give a more explicit error to the developer
30+ fail("""
31+ It looks like you have an unconsumed event in your test.
32+ If you get this error, it means that your test is missing to consume one of several events.
33+ You can fix by consuming and check the event with `awaitItem()`, or you can also invoke
34+ `cancelAndIgnoreRemainingEvents()`.
35+ """ .trimIndent())
36+ }
37+ throw t
38+ }
2539}
You can’t perform that action at this time.
0 commit comments