assertThrows

public abstract E assertThrows<E extends Throwable>(Class<E> type, Supplier<String> messageSupplier)(source)

Asserts that the call resulted in a throwable of type type and returns the throwable. Otherwise, an AssertionFailedError containing the message supplied by messageSupplier will be thrown. messageSupplier is allowed to supply null.

Return

the throwable resulted by the call

Parameters

type

the type of the expected throwable

messageSupplier

a supplier for the message if the throwable was not thrown

<E>

the type of the expected throwable

See also

Throws

AssertionFailedError

if the call did not result in a throwable of type type


public E assertThrows<E extends Throwable>(Class<E> type, String message)(source)

Asserts that the call resulted in a throwable of type type and returns the throwable. Otherwise, an AssertionFailedError containing message will be thrown.

Return

the throwable resulted by the call

Parameters

type

the type of the expected throwable

message

the message if the expected throwable was not thrown

<E>

the type of the expected throwable

Throws

AssertionFailedError

if the call did not result in a throwable of type type


public E assertThrows<E extends Throwable>(Class<E> type)(source)

Asserts that the call resulted in n throwable of type type and returns the throwable. Otherwise, an AssertionFailedError will be thrown.

Return

the throwable resulted by the call

Parameters

type

the type of the expected throwable

<E>

the type of the expected throwable

Throws

AssertionFailedError

if the call did not result in a throwable of type type