Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Document that assertThrows allows exception subtypes #3729

Merged
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -3105,11 +3105,16 @@ public static <T extends Throwable> T assertThrowsExactly(Class<T> expectedType,
* <em>Assert</em> that execution of the supplied {@code executable} throws
* an exception of the {@code expectedType} and return the exception.
*
* <p>If no exception is thrown, or if an exception of a different type is
* thrown, this method will fail.
* <p>The assertion passes if the thrown exception type is the same as
* {@code expectedType} or a subtype of it. To check for the exact thrown
marcphilipp marked this conversation as resolved.
Show resolved Hide resolved
* type use {@link #assertThrowsExactly(Class, Executable) assertThrowsExactly}.
* If no exception is thrown, or if an exception of a different type is thrown,
* this method will fail.
*
* <p>If you do not want to perform additional checks on the exception instance,
* ignore the return value.
*
* @see #assertThrowsExactly(Class, Executable)
*/
public static <T extends Throwable> T assertThrows(Class<T> expectedType, Executable executable) {
return AssertThrows.assertThrows(expectedType, executable);
Expand All @@ -3119,13 +3124,18 @@ public static <T extends Throwable> T assertThrows(Class<T> expectedType, Execut
* <em>Assert</em> that execution of the supplied {@code executable} throws
* an exception of the {@code expectedType} and return the exception.
*
* <p>If no exception is thrown, or if an exception of a different type is
* thrown, this method will fail.
* <p>The assertion passes if the thrown exception type is the same as
* {@code expectedType} or a subtype of it. To check for the exact thrown
marcphilipp marked this conversation as resolved.
Show resolved Hide resolved
* type use {@link #assertThrowsExactly(Class, Executable, String) assertThrowsExactly}.
* If no exception is thrown, or if an exception of a different type is thrown,
* this method will fail.
*
* <p>If you do not want to perform additional checks on the exception instance,
* ignore the return value.
*
* <p>Fails with the supplied failure {@code message}.
*
* @see #assertThrowsExactly(Class, Executable, String)
*/
public static <T extends Throwable> T assertThrows(Class<T> expectedType, Executable executable, String message) {
return AssertThrows.assertThrows(expectedType, executable, message);
Expand All @@ -3135,14 +3145,19 @@ public static <T extends Throwable> T assertThrows(Class<T> expectedType, Execut
* <em>Assert</em> that execution of the supplied {@code executable} throws
* an exception of the {@code expectedType} and return the exception.
*
* <p>If no exception is thrown, or if an exception of a different type is
* thrown, this method will fail.
* <p>The assertion passes if the thrown exception type is the same as
* {@code expectedType} or a subtype of it. To check for the exact thrown
marcphilipp marked this conversation as resolved.
Show resolved Hide resolved
* type use {@link #assertThrowsExactly(Class, Executable, Supplier) assertThrowsExactly}.
* If no exception is thrown, or if an exception of a different type is thrown,
* this method will fail.
*
* <p>If necessary, the failure message will be retrieved lazily from the
* supplied {@code messageSupplier}.
*
* <p>If you do not want to perform additional checks on the exception instance,
* ignore the return value.
*
* @see #assertThrowsExactly(Class, Executable, Supplier)
*/
public static <T extends Throwable> T assertThrows(Class<T> expectedType, Executable executable,
Supplier<String> messageSupplier) {
Expand Down