Skip to content

Commit 69b6822

Browse files
committed
Add an expected failure util to catch assertion error for known bugs without failing the tests.
1 parent 4bbcc9f commit 69b6822

1 file changed

Lines changed: 13 additions & 0 deletions

File tree

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package org.fossify.calendar.testing
2+
3+
fun expectedFailure(testName: String = "", block: () -> Unit) {
4+
try {
5+
block()
6+
println("WARNING: Expected failure test '$testName' passed unexpectedly.")
7+
} catch (e: Throwable) {
8+
println("Expected failure in test '$testName': ${e.javaClass.simpleName}: ${e.message}")
9+
return
10+
}
11+
12+
throw AssertionError("Expected failure test '$testName' passed unexpectedly. Investigate: bug may be fixed.")
13+
}

0 commit comments

Comments
 (0)