public final class ShouldThrow extends Object
Modifier and Type | Method and Description |
---|---|
static <ThrowableType extends Throwable> |
shouldThrow(Class<ThrowableType> expectedThrowableType,
Runnable workThatShouldThrowThrowable)
Asserts that a code block throws a
Throwable of the given type and returns it to permit further assertions on the
Throwable instance returned. |
static <ThrowableType extends Throwable> |
shouldThrow(Class<ThrowableType> expectedThrowableType,
String message,
Runnable workThatShouldThrowThrowable)
Asserts that a code block throws a
Throwable of the given type and returns it to permit further assertions on the
Throwable instance returned. |
public static <ThrowableType extends Throwable> ThrowableType shouldThrow(Class<ThrowableType> expectedThrowableType, Runnable workThatShouldThrowThrowable)
Throwable
of the given type and returns it to permit further assertions on the
Throwable instance returned.ThrowableType
- the type of the throwable the code block should throwexpectedThrowableType
- the class of the throwable the code block should throwworkThatShouldThrowThrowable
- a code block that ought to throw the expected type when evaluatedAssertionError
- if no Throwable is thrown at all whilst executing the code blockThrowable
- any other Throwable thrown by the code block that is not an instance of the expected typepublic static <ThrowableType extends Throwable> ThrowableType shouldThrow(Class<ThrowableType> expectedThrowableType, String message, Runnable workThatShouldThrowThrowable)
Throwable
of the given type and returns it to permit further assertions on the
Throwable instance returned.ThrowableType
- the type of the throwable the code block should throwexpectedThrowableType
- the class of the throwable the code block should throwmessage
- the message to be used as the message of the AssertionError if no throwable is thrown at allworkThatShouldThrowThrowable
- a code block that ought to throw the expected type when evaluatedAssertionError
- if no Throwable is thrown at all whilst executing the code blockThrowable
- any other Throwable thrown by the code block that is not an instance of the expected typeCopyright © 2013. All Rights Reserved.