public final class Asserts extends Object
Including some JUnit v5 NG APIs for JUnit 4 already.
Modifier and Type | Class and Description |
---|---|
static interface |
Asserts.JUnitExecutable
Functional interface that can be used to implement any generic block of code that potentially throws a Throwable.
|
Modifier and Type | Method and Description |
---|---|
static <T extends Throwable> |
assertThrows(Class<T> expectedThrowable,
Asserts.JUnitExecutable exec)
Asserts that execution of the supplied executable throws an exception of the
expectedType and returns the exception.
|
public static <T extends Throwable> T assertThrows(Class<T> expectedThrowable, Asserts.JUnitExecutable exec)
This is useful to avoid (and comply with) Error Prone's TestExceptionChecker bug pattern.
If no exception is thrown, or if an exception of a different type is thrown, this method will fail.
If you do not want to perform additional checks on the exception instance, simply ignore the return value.
Back-ported from org.junit.jupiter.api.Assertions.
Copyright © 2019 OpenDaylight. All rights reserved.