public class AnyThrowableHandlingKt
| Modifier and Type | Method and Description |
|---|---|
static void |
shouldNotThrowAny(kotlin.jvm.functions.Function0<kotlin.Unit> block)
Verifies that a block of code does NOT throw any Throwable
|
static void |
shouldNotThrowAnyUnit(kotlin.jvm.functions.Function0<kotlin.Unit> block)
Verifies that a block of code does NOT throw any Throwable
|
static java.lang.Throwable |
shouldThrowAny(kotlin.jvm.functions.Function0<? extends java.lang.Object> block)
Verifies that a block of code throws any Throwable
|
static java.lang.Throwable |
shouldThrowAnyUnit(kotlin.jvm.functions.Function0<kotlin.Unit> block)
Verifies that a block of code throws any Throwable
|
public static java.lang.Throwable shouldThrowAnyUnit(kotlin.jvm.functions.Function0<kotlin.Unit> block)
Verifies that a block of code throws any Throwable
Use function to wrap a block of code that you want to verify that throws any kind of Throwable, where using
AnyThrowableHandlingKt.shouldThrowAny can't be used for any reason, such as an assignment of a variable (assignments are statements,
therefore has no return value).
If you want to verify a specific Throwable, use shouldThrowExactlyUnit.
If you want to verify a Throwable and any subclass, use shouldThrowUnit.
public static void shouldNotThrowAnyUnit(kotlin.jvm.functions.Function0<kotlin.Unit> block)
Verifies that a block of code does NOT throw any Throwable
Use function to wrap a block of code that you want to make sure doesn't throw any Throwable,
where using AnyThrowableHandlingKt.shouldNotThrowAny can't be used for any reason, such as an assignment of a variable (assignments are
statements, therefore has no return value).
Note that executing this code is no different to executing block itself, as any uncaught exception will be propagated up anyways.
public static java.lang.Throwable shouldThrowAny(kotlin.jvm.functions.Function0<? extends java.lang.Object> block)
Verifies that a block of code throws any Throwable
Use function to wrap a block of code that you want to verify that throws any kind of Throwable.
If you want to verify a specific Throwable, use shouldThrowExactly.
If you want to verify a Throwable and any subclasses, use shouldThrow
Attention to assignment operations:
When doing an assignment to a variable, the code won't compile, because an assignment is not of type Any, as required
by block. If you need to test that an assignment throws a Throwable, use AnyThrowableHandlingKt.shouldThrowAnyUnit or it's variations.
val thrownThrowable: Throwable = shouldThrowAny {
throw FooException() // This is a random Throwable, could be anything
}
public static void shouldNotThrowAny(kotlin.jvm.functions.Function0<kotlin.Unit> block)
Verifies that a block of code does NOT throw any Throwable
Use function to wrap a block of code that you want to make sure doesn't throw any Throwable.
Note that executing this code is no different to executing block itself, as any uncaught exception will be propagated up anyways.
Attention to assignment operations:
When doing an assignment to a variable, the code won't compile, because an assignment is not of type Any, as required
by block. If you need to test that an assignment doesn't throw a Throwable, use AnyThrowableHandlingKt.shouldNotThrowAnyUnit or it's
variations.