Allow call assertFailsWith<T> with default message.
This commit is contained in:
@@ -37,7 +37,7 @@ fun <T : Throwable> assertFailsWith(exceptionClass: KClass<T>, message: String?,
|
||||
/** Asserts that a [block] fails with a specific exception of type [T] being thrown.
|
||||
* Since inline method doesn't allow to trace where it was invoked, it is required to pass a [message] to distinguish this method call from others.
|
||||
*/
|
||||
inline fun <reified T : Throwable> assertFailsWith(message: String, noinline block: () -> Unit): T = assertFailsWith(T::class, message, block)
|
||||
inline fun <reified T : Throwable> assertFailsWith(message: String? = null, noinline block: () -> Unit): T = assertFailsWith(T::class, message, block)
|
||||
|
||||
|
||||
/**
|
||||
|
||||
@@ -20,7 +20,7 @@ class BasicAssertionsJVMTest {
|
||||
|
||||
@Test
|
||||
fun testFailsWithMessage() {
|
||||
assertFailsWith<IllegalArgumentException>("") {
|
||||
assertFailsWith<IllegalArgumentException>() {
|
||||
throw IllegalArgumentException()
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user