Allow call assertFailsWith<T> with default message.

This commit is contained in:
Ilya Gorbunov
2016-01-27 19:54:31 +03:00
parent 7e26fa6002
commit 3d468aaab9
2 changed files with 2 additions and 2 deletions
@@ -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()
}
}