Skip to content

Commit 662c002

Browse files
committed
Make sure lambdaError() make the test fail in all circumstances.
1 parent 0e5fc8f commit 662c002

File tree

1 file changed

+12
-1
lines changed
  • tests/testutils/src/main/kotlin/io/element/android/tests/testutils/lambda

1 file changed

+12
-1
lines changed

tests/testutils/src/main/kotlin/io/element/android/tests/testutils/lambda/Error.kt

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,19 @@
77

88
package io.element.android.tests.testutils.lambda
99

10+
import kotlin.system.exitProcess
11+
1012
fun lambdaError(
1113
message: String = "This lambda should never be called."
1214
): Nothing {
13-
throw AssertionError(message)
15+
// Throwing an exception here is not enough, it can be caught.
16+
// Instead exit the process to make sure the test fails.
17+
// The error will be:
18+
// "Could not stop all services."
19+
// In this case, but a breakpoint here and run the test in debug mode to identify which lambda is failing.
20+
System.err.println(message)
21+
Thread.currentThread().stackTrace.forEach {
22+
System.err.println(it)
23+
}
24+
exitProcess(1)
1425
}

0 commit comments

Comments
 (0)