Class Assertions
- java.lang.Object
-
- org.junit.jupiter.api.Assertions
-
@API(status=STABLE, since="5.0") public final class Assertions extends java.lang.Object
Assertions
is a collection of utility methods that support asserting conditions in tests.Additional Kotlin assertions can be found as top-level functions in the
org.junit.jupiter.api
package.Unless otherwise noted, a failed assertion will throw an
AssertionFailedError
or a subclass thereof.- Since:
- 5.0
- See Also:
AssertionFailedError
,Assumptions
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static void
assertAll(java.lang.String heading, java.util.Collection<Executable> executables)
Asserts that all suppliedexecutables
do not throw exceptions.static void
assertAll(java.lang.String heading, java.util.stream.Stream<Executable> executables)
Asserts that all suppliedexecutables
do not throw exceptions.static void
assertAll(java.lang.String heading, Executable... executables)
Asserts that all suppliedexecutables
do not throw exceptions.static void
assertAll(java.util.Collection<Executable> executables)
Asserts that all suppliedexecutables
do not throw exceptions.static void
assertAll(java.util.stream.Stream<Executable> executables)
Asserts that all suppliedexecutables
do not throw exceptions.static void
assertAll(Executable... executables)
Asserts that all suppliedexecutables
do not throw exceptions.static void
assertArrayEquals(boolean[] expected, boolean[] actual)
Asserts thatexpected
andactual
boolean arrays are equal.static void
assertArrayEquals(boolean[] expected, boolean[] actual, java.lang.String message)
Asserts thatexpected
andactual
boolean arrays are equal.static void
assertArrayEquals(boolean[] expected, boolean[] actual, java.util.function.Supplier<java.lang.String> messageSupplier)
Asserts thatexpected
andactual
boolean arrays are equal.static void
assertArrayEquals(byte[] expected, byte[] actual)
Asserts thatexpected
andactual
byte arrays are equal.static void
assertArrayEquals(byte[] expected, byte[] actual, java.lang.String message)
Asserts thatexpected
andactual
byte arrays are equal.static void
assertArrayEquals(byte[] expected, byte[] actual, java.util.function.Supplier<java.lang.String> messageSupplier)
Asserts thatexpected
andactual
byte arrays are equal.static void
assertArrayEquals(char[] expected, char[] actual)
Asserts thatexpected
andactual
char arrays are equal.static void
assertArrayEquals(char[] expected, char[] actual, java.lang.String message)
Asserts thatexpected
andactual
char arrays are equal.static void
assertArrayEquals(char[] expected, char[] actual, java.util.function.Supplier<java.lang.String> messageSupplier)
Asserts thatexpected
andactual
char arrays are equal.static void
assertArrayEquals(double[] expected, double[] actual)
Asserts thatexpected
andactual
double arrays are equal.static void
assertArrayEquals(double[] expected, double[] actual, double delta)
Asserts thatexpected
andactual
double arrays are equal within the givendelta
.static void
assertArrayEquals(double[] expected, double[] actual, double delta, java.lang.String message)
Asserts thatexpected
andactual
double arrays are equal within the givendelta
.static void
assertArrayEquals(double[] expected, double[] actual, double delta, java.util.function.Supplier<java.lang.String> messageSupplier)
Asserts thatexpected
andactual
double arrays are equal within the givendelta
.static void
assertArrayEquals(double[] expected, double[] actual, java.lang.String message)
Asserts thatexpected
andactual
double arrays are equal.static void
assertArrayEquals(double[] expected, double[] actual, java.util.function.Supplier<java.lang.String> messageSupplier)
Asserts thatexpected
andactual
double arrays are equal.static void
assertArrayEquals(float[] expected, float[] actual)
Asserts thatexpected
andactual
float arrays are equal.static void
assertArrayEquals(float[] expected, float[] actual, float delta)
Asserts thatexpected
andactual
float arrays are equal within the givendelta
.static void
assertArrayEquals(float[] expected, float[] actual, float delta, java.lang.String message)
Asserts thatexpected
andactual
float arrays are equal within the givendelta
.static void
assertArrayEquals(float[] expected, float[] actual, float delta, java.util.function.Supplier<java.lang.String> messageSupplier)
Asserts thatexpected
andactual
float arrays are equal within the givendelta
.static void
assertArrayEquals(float[] expected, float[] actual, java.lang.String message)
Asserts thatexpected
andactual
float arrays are equal.static void
assertArrayEquals(float[] expected, float[] actual, java.util.function.Supplier<java.lang.String> messageSupplier)
Asserts thatexpected
andactual
float arrays are equal.static void
assertArrayEquals(int[] expected, int[] actual)
Asserts thatexpected
andactual
int arrays are equal.static void
assertArrayEquals(int[] expected, int[] actual, java.lang.String message)
Asserts thatexpected
andactual
int arrays are equal.static void
assertArrayEquals(int[] expected, int[] actual, java.util.function.Supplier<java.lang.String> messageSupplier)
Asserts thatexpected
andactual
int arrays are equal.static void
assertArrayEquals(long[] expected, long[] actual)
Asserts thatexpected
andactual
long arrays are equal.static void
assertArrayEquals(long[] expected, long[] actual, java.lang.String message)
Asserts thatexpected
andactual
long arrays are equal.static void
assertArrayEquals(long[] expected, long[] actual, java.util.function.Supplier<java.lang.String> messageSupplier)
Asserts thatexpected
andactual
long arrays are equal.static void
assertArrayEquals(short[] expected, short[] actual)
Asserts thatexpected
andactual
short arrays are equal.static void
assertArrayEquals(short[] expected, short[] actual, java.lang.String message)
Asserts thatexpected
andactual
short arrays are equal.static void
assertArrayEquals(short[] expected, short[] actual, java.util.function.Supplier<java.lang.String> messageSupplier)
Asserts thatexpected
andactual
short arrays are equal.static void
assertArrayEquals(java.lang.Object[] expected, java.lang.Object[] actual)
Asserts thatexpected
andactual
object arrays are deeply equal.static void
assertArrayEquals(java.lang.Object[] expected, java.lang.Object[] actual, java.lang.String message)
Asserts thatexpected
andactual
object arrays are deeply equal.static void
assertArrayEquals(java.lang.Object[] expected, java.lang.Object[] actual, java.util.function.Supplier<java.lang.String> messageSupplier)
Asserts thatexpected
andactual
object arrays are deeply equal.static void
assertEquals(byte expected, byte actual)
Asserts thatexpected
andactual
are equal.static void
assertEquals(byte expected, byte actual, java.lang.String message)
Asserts thatexpected
andactual
are equal.static void
assertEquals(byte expected, byte actual, java.util.function.Supplier<java.lang.String> messageSupplier)
Asserts thatexpected
andactual
are equal.static void
assertEquals(char expected, char actual)
Asserts thatexpected
andactual
are equal.static void
assertEquals(char expected, char actual, java.lang.String message)
Asserts thatexpected
andactual
are equal.static void
assertEquals(char expected, char actual, java.util.function.Supplier<java.lang.String> messageSupplier)
Asserts thatexpected
andactual
are equal.static void
assertEquals(double expected, double actual)
Asserts thatexpected
andactual
are equal.static void
assertEquals(double expected, double actual, double delta)
Asserts thatexpected
andactual
are equal within the givendelta
.static void
assertEquals(double expected, double actual, double delta, java.lang.String message)
Asserts thatexpected
andactual
are equal within the givendelta
.static void
assertEquals(double expected, double actual, double delta, java.util.function.Supplier<java.lang.String> messageSupplier)
Asserts thatexpected
andactual
are equal within the givendelta
.static void
assertEquals(double expected, double actual, java.lang.String message)
Asserts thatexpected
andactual
are equal.static void
assertEquals(double expected, double actual, java.util.function.Supplier<java.lang.String> messageSupplier)
Asserts thatexpected
andactual
are equal.static void
assertEquals(float expected, float actual)
Asserts thatexpected
andactual
are equal.static void
assertEquals(float expected, float actual, float delta)
Asserts thatexpected
andactual
are equal within the givendelta
.static void
assertEquals(float expected, float actual, float delta, java.lang.String message)
Asserts thatexpected
andactual
are equal within the givendelta
.static void
assertEquals(float expected, float actual, float delta, java.util.function.Supplier<java.lang.String> messageSupplier)
Asserts thatexpected
andactual
are equal within the givendelta
.static void
assertEquals(float expected, float actual, java.lang.String message)
Asserts thatexpected
andactual
are equal.static void
assertEquals(float expected, float actual, java.util.function.Supplier<java.lang.String> messageSupplier)
Asserts thatexpected
andactual
are equal.static void
assertEquals(int expected, int actual)
Asserts thatexpected
andactual
are equal.static void
assertEquals(int expected, int actual, java.lang.String message)
Asserts thatexpected
andactual
are equal.static void
assertEquals(int expected, int actual, java.util.function.Supplier<java.lang.String> messageSupplier)
Asserts thatexpected
andactual
are equal.static void
assertEquals(long expected, long actual)
Asserts thatexpected
andactual
are equal.static void
assertEquals(long expected, long actual, java.lang.String message)
Asserts thatexpected
andactual
are equal.static void
assertEquals(long expected, long actual, java.util.function.Supplier<java.lang.String> messageSupplier)
Asserts thatexpected
andactual
are equal.static void
assertEquals(short expected, short actual)
Asserts thatexpected
andactual
are equal.static void
assertEquals(short expected, short actual, java.lang.String message)
Asserts thatexpected
andactual
are equal.static void
assertEquals(short expected, short actual, java.util.function.Supplier<java.lang.String> messageSupplier)
Asserts thatexpected
andactual
are equal.static void
assertEquals(java.lang.Object expected, java.lang.Object actual)
Asserts thatexpected
andactual
are equal.static void
assertEquals(java.lang.Object expected, java.lang.Object actual, java.lang.String message)
Asserts thatexpected
andactual
are equal.static void
assertEquals(java.lang.Object expected, java.lang.Object actual, java.util.function.Supplier<java.lang.String> messageSupplier)
Asserts thatexpected
andactual
are equal.static void
assertFalse(boolean condition)
Asserts that the suppliedcondition
is nottrue
.static void
assertFalse(boolean condition, java.lang.String message)
Asserts that the suppliedcondition
is nottrue
.static void
assertFalse(boolean condition, java.util.function.Supplier<java.lang.String> messageSupplier)
Asserts that the suppliedcondition
is nottrue
.static void
assertFalse(java.util.function.BooleanSupplier booleanSupplier)
Asserts that the boolean condition supplied bybooleanSupplier
is nottrue
.static void
assertFalse(java.util.function.BooleanSupplier booleanSupplier, java.lang.String message)
Asserts that the boolean condition supplied bybooleanSupplier
is nottrue
.static void
assertFalse(java.util.function.BooleanSupplier booleanSupplier, java.util.function.Supplier<java.lang.String> messageSupplier)
Asserts that the boolean condition supplied bybooleanSupplier
is nottrue
.static void
assertIterableEquals(java.lang.Iterable<?> expected, java.lang.Iterable<?> actual)
Asserts thatexpected
andactual
iterables are deeply equal.static void
assertIterableEquals(java.lang.Iterable<?> expected, java.lang.Iterable<?> actual, java.lang.String message)
Asserts thatexpected
andactual
iterables are deeply equal.static void
assertIterableEquals(java.lang.Iterable<?> expected, java.lang.Iterable<?> actual, java.util.function.Supplier<java.lang.String> messageSupplier)
Asserts thatexpected
andactual
iterables are deeply equal.static void
assertLinesMatch(java.util.List<java.lang.String> expectedLines, java.util.List<java.lang.String> actualLines)
Asserts thatexpected
list of Strings matchesactual
list.static void
assertNotEquals(java.lang.Object unexpected, java.lang.Object actual)
Asserts thatexpected
andactual
are not equal.static void
assertNotEquals(java.lang.Object unexpected, java.lang.Object actual, java.lang.String message)
Asserts thatexpected
andactual
are not equal.static void
assertNotEquals(java.lang.Object unexpected, java.lang.Object actual, java.util.function.Supplier<java.lang.String> messageSupplier)
Asserts thatexpected
andactual
are not equal.static void
assertNotNull(java.lang.Object actual)
Asserts thatactual
is notnull
.static void
assertNotNull(java.lang.Object actual, java.lang.String message)
Asserts thatactual
is notnull
.static void
assertNotNull(java.lang.Object actual, java.util.function.Supplier<java.lang.String> messageSupplier)
Asserts thatactual
is notnull
.static void
assertNotSame(java.lang.Object unexpected, java.lang.Object actual)
Asserts thatexpected
andactual
do not refer to the same object.static void
assertNotSame(java.lang.Object unexpected, java.lang.Object actual, java.lang.String message)
Asserts thatexpected
andactual
do not refer to the same object.static void
assertNotSame(java.lang.Object unexpected, java.lang.Object actual, java.util.function.Supplier<java.lang.String> messageSupplier)
Asserts thatexpected
andactual
do not refer to the same object.static void
assertNull(java.lang.Object actual)
Asserts thatactual
isnull
.static void
assertNull(java.lang.Object actual, java.lang.String message)
Asserts thatactual
isnull
.static void
assertNull(java.lang.Object actual, java.util.function.Supplier<java.lang.String> messageSupplier)
Asserts thatactual
isnull
.static void
assertSame(java.lang.Object expected, java.lang.Object actual)
Asserts thatexpected
andactual
refer to the same object.static void
assertSame(java.lang.Object expected, java.lang.Object actual, java.lang.String message)
Asserts thatexpected
andactual
refer to the same object.static void
assertSame(java.lang.Object expected, java.lang.Object actual, java.util.function.Supplier<java.lang.String> messageSupplier)
Asserts thatexpected
andactual
refer to the same object.static <T extends java.lang.Throwable>
TassertThrows(java.lang.Class<T> expectedType, Executable executable)
Asserts that execution of the suppliedexecutable
throws an exception of theexpectedType
and returns the exception.static <T extends java.lang.Throwable>
TassertThrows(java.lang.Class<T> expectedType, Executable executable, java.lang.String message)
Asserts that execution of the suppliedexecutable
throws an exception of theexpectedType
and returns the exception.static <T extends java.lang.Throwable>
TassertThrows(java.lang.Class<T> expectedType, Executable executable, java.util.function.Supplier<java.lang.String> messageSupplier)
Asserts that execution of the suppliedexecutable
throws an exception of theexpectedType
and returns the exception.static void
assertTimeout(java.time.Duration timeout, Executable executable)
Asserts that execution of the suppliedexecutable
completes before the giventimeout
is exceeded.static void
assertTimeout(java.time.Duration timeout, Executable executable, java.lang.String message)
Asserts that execution of the suppliedexecutable
completes before the giventimeout
is exceeded.static void
assertTimeout(java.time.Duration timeout, Executable executable, java.util.function.Supplier<java.lang.String> messageSupplier)
Asserts that execution of the suppliedexecutable
completes before the giventimeout
is exceeded.static <T> T
assertTimeout(java.time.Duration timeout, ThrowingSupplier<T> supplier)
Asserts that execution of the suppliedsupplier
completes before the giventimeout
is exceeded.static <T> T
assertTimeout(java.time.Duration timeout, ThrowingSupplier<T> supplier, java.lang.String message)
Asserts that execution of the suppliedsupplier
completes before the giventimeout
is exceeded.static <T> T
assertTimeout(java.time.Duration timeout, ThrowingSupplier<T> supplier, java.util.function.Supplier<java.lang.String> messageSupplier)
Asserts that execution of the suppliedsupplier
completes before the giventimeout
is exceeded.static void
assertTimeoutPreemptively(java.time.Duration timeout, Executable executable)
Asserts that execution of the suppliedexecutable
completes before the giventimeout
is exceeded.static void
assertTimeoutPreemptively(java.time.Duration timeout, Executable executable, java.lang.String message)
Asserts that execution of the suppliedexecutable
completes before the giventimeout
is exceeded.static void
assertTimeoutPreemptively(java.time.Duration timeout, Executable executable, java.util.function.Supplier<java.lang.String> messageSupplier)
Asserts that execution of the suppliedexecutable
completes before the giventimeout
is exceeded.static <T> T
assertTimeoutPreemptively(java.time.Duration timeout, ThrowingSupplier<T> supplier)
Asserts that execution of the suppliedsupplier
completes before the giventimeout
is exceeded.static <T> T
assertTimeoutPreemptively(java.time.Duration timeout, ThrowingSupplier<T> supplier, java.lang.String message)
Asserts that execution of the suppliedsupplier
completes before the giventimeout
is exceeded.static <T> T
assertTimeoutPreemptively(java.time.Duration timeout, ThrowingSupplier<T> supplier, java.util.function.Supplier<java.lang.String> messageSupplier)
Asserts that execution of the suppliedsupplier
completes before the giventimeout
is exceeded.static void
assertTrue(boolean condition)
Asserts that the suppliedcondition
istrue
.static void
assertTrue(boolean condition, java.lang.String message)
Asserts that the suppliedcondition
istrue
.static void
assertTrue(boolean condition, java.util.function.Supplier<java.lang.String> messageSupplier)
Asserts that the suppliedcondition
istrue
.static void
assertTrue(java.util.function.BooleanSupplier booleanSupplier)
Asserts that the boolean condition supplied bybooleanSupplier
istrue
.static void
assertTrue(java.util.function.BooleanSupplier booleanSupplier, java.lang.String message)
Asserts that the boolean condition supplied bybooleanSupplier
istrue
.static void
assertTrue(java.util.function.BooleanSupplier booleanSupplier, java.util.function.Supplier<java.lang.String> messageSupplier)
Asserts that the boolean condition supplied bybooleanSupplier
istrue
.static <V> V
fail(java.lang.String message)
Fails a test with the given failuremessage
.static <V> V
fail(java.lang.String message, java.lang.Throwable cause)
Fails a test with the given failuremessage
as well as the underlyingcause
.static <V> V
fail(java.lang.Throwable cause)
Fails a test with the given underlyingcause
.static <V> V
fail(java.util.function.Supplier<java.lang.String> messageSupplier)
Fails a test with the failure message retrieved from the givenmessageSupplier
.
-
-
-
Method Detail
-
fail
public static <V> V fail(java.lang.String message)
Fails a test with the given failuremessage
.See Javadoc for
fail(String, Throwable)
for an explanation of this method's generic return typeV
.
-
fail
public static <V> V fail(java.lang.String message, java.lang.Throwable cause)
Fails a test with the given failuremessage
as well as the underlyingcause
.The generic return type
V
allows this method to be used directly as a single-statement lambda expression, thereby avoiding the need to implement a code block with an explicit return value. Since this method throws anAssertionFailedError
before its return statement, this method never actually returns a value to its caller. The following example demonstrates how this may be used in practice.Stream.of().map(entry -> fail("should not be called"));
-
fail
public static <V> V fail(java.lang.Throwable cause)
Fails a test with the given underlyingcause
.See Javadoc for
fail(String, Throwable)
for an explanation of this method's generic return typeV
.
-
fail
public static <V> V fail(java.util.function.Supplier<java.lang.String> messageSupplier)
Fails a test with the failure message retrieved from the givenmessageSupplier
.See Javadoc for
fail(String, Throwable)
for an explanation of this method's generic return typeV
.
-
assertTrue
public static void assertTrue(boolean condition)
Asserts that the suppliedcondition
istrue
.
-
assertTrue
public static void assertTrue(boolean condition, java.util.function.Supplier<java.lang.String> messageSupplier)
Asserts that the suppliedcondition
istrue
.If necessary, the failure message will be retrieved lazily from the supplied
messageSupplier
.
-
assertTrue
public static void assertTrue(java.util.function.BooleanSupplier booleanSupplier)
Asserts that the boolean condition supplied bybooleanSupplier
istrue
.
-
assertTrue
public static void assertTrue(java.util.function.BooleanSupplier booleanSupplier, java.lang.String message)
Asserts that the boolean condition supplied bybooleanSupplier
istrue
.Fails with the supplied failure
message
.
-
assertTrue
public static void assertTrue(boolean condition, java.lang.String message)
Asserts that the suppliedcondition
istrue
.Fails with the supplied failure
message
.
-
assertTrue
public static void assertTrue(java.util.function.BooleanSupplier booleanSupplier, java.util.function.Supplier<java.lang.String> messageSupplier)
Asserts that the boolean condition supplied bybooleanSupplier
istrue
.If necessary, the failure message will be retrieved lazily from the supplied
messageSupplier
.
-
assertFalse
public static void assertFalse(boolean condition)
Asserts that the suppliedcondition
is nottrue
.
-
assertFalse
public static void assertFalse(boolean condition, java.lang.String message)
Asserts that the suppliedcondition
is nottrue
.Fails with the supplied failure
message
.
-
assertFalse
public static void assertFalse(boolean condition, java.util.function.Supplier<java.lang.String> messageSupplier)
Asserts that the suppliedcondition
is nottrue
.If necessary, the failure message will be retrieved lazily from the supplied
messageSupplier
.
-
assertFalse
public static void assertFalse(java.util.function.BooleanSupplier booleanSupplier)
Asserts that the boolean condition supplied bybooleanSupplier
is nottrue
.
-
assertFalse
public static void assertFalse(java.util.function.BooleanSupplier booleanSupplier, java.lang.String message)
Asserts that the boolean condition supplied bybooleanSupplier
is nottrue
.Fails with the supplied failure
message
.
-
assertFalse
public static void assertFalse(java.util.function.BooleanSupplier booleanSupplier, java.util.function.Supplier<java.lang.String> messageSupplier)
Asserts that the boolean condition supplied bybooleanSupplier
is nottrue
.If necessary, the failure message will be retrieved lazily from the supplied
messageSupplier
.
-
assertNull
public static void assertNull(java.lang.Object actual)
Asserts thatactual
isnull
.
-
assertNull
public static void assertNull(java.lang.Object actual, java.lang.String message)
Asserts thatactual
isnull
.Fails with the supplied failure
message
.
-
assertNull
public static void assertNull(java.lang.Object actual, java.util.function.Supplier<java.lang.String> messageSupplier)
Asserts thatactual
isnull
.If necessary, the failure message will be retrieved lazily from the supplied
messageSupplier
.
-
assertNotNull
public static void assertNotNull(java.lang.Object actual)
Asserts thatactual
is notnull
.
-
assertNotNull
public static void assertNotNull(java.lang.Object actual, java.lang.String message)
Asserts thatactual
is notnull
.Fails with the supplied failure
message
.
-
assertNotNull
public static void assertNotNull(java.lang.Object actual, java.util.function.Supplier<java.lang.String> messageSupplier)
Asserts thatactual
is notnull
.If necessary, the failure message will be retrieved lazily from the supplied
messageSupplier
.
-
assertEquals
public static void assertEquals(short expected, short actual)
Asserts thatexpected
andactual
are equal.
-
assertEquals
public static void assertEquals(short expected, short actual, java.lang.String message)
Asserts thatexpected
andactual
are equal.
-
assertEquals
public static void assertEquals(short expected, short actual, java.util.function.Supplier<java.lang.String> messageSupplier)
Asserts thatexpected
andactual
are equal.If necessary, the failure message will be retrieved lazily from the supplied
messageSupplier
.
-
assertEquals
public static void assertEquals(byte expected, byte actual)
Asserts thatexpected
andactual
are equal.
-
assertEquals
public static void assertEquals(byte expected, byte actual, java.lang.String message)
Asserts thatexpected
andactual
are equal.
-
assertEquals
public static void assertEquals(byte expected, byte actual, java.util.function.Supplier<java.lang.String> messageSupplier)
Asserts thatexpected
andactual
are equal.If necessary, the failure message will be retrieved lazily from the supplied
messageSupplier
.
-
assertEquals
public static void assertEquals(int expected, int actual)
Asserts thatexpected
andactual
are equal.
-
assertEquals
public static void assertEquals(int expected, int actual, java.lang.String message)
Asserts thatexpected
andactual
are equal.
-
assertEquals
public static void assertEquals(int expected, int actual, java.util.function.Supplier<java.lang.String> messageSupplier)
Asserts thatexpected
andactual
are equal.If necessary, the failure message will be retrieved lazily from the supplied
messageSupplier
.
-
assertEquals
public static void assertEquals(long expected, long actual)
Asserts thatexpected
andactual
are equal.
-
assertEquals
public static void assertEquals(long expected, long actual, java.lang.String message)
Asserts thatexpected
andactual
are equal.
-
assertEquals
public static void assertEquals(long expected, long actual, java.util.function.Supplier<java.lang.String> messageSupplier)
Asserts thatexpected
andactual
are equal.If necessary, the failure message will be retrieved lazily from the supplied
messageSupplier
.
-
assertEquals
public static void assertEquals(char expected, char actual)
Asserts thatexpected
andactual
are equal.
-
assertEquals
public static void assertEquals(char expected, char actual, java.lang.String message)
Asserts thatexpected
andactual
are equal.
-
assertEquals
public static void assertEquals(char expected, char actual, java.util.function.Supplier<java.lang.String> messageSupplier)
Asserts thatexpected
andactual
are equal.If necessary, the failure message will be retrieved lazily from the supplied
messageSupplier
.
-
assertEquals
public static void assertEquals(float expected, float actual)
Asserts thatexpected
andactual
are equal.Equality imposed by this method is consistent with
Float.equals(Object)
andFloat.compare(float, float)
.
-
assertEquals
public static void assertEquals(float expected, float actual, java.lang.String message)
Asserts thatexpected
andactual
are equal.Equality imposed by this method is consistent with
Float.equals(Object)
andFloat.compare(float, float)
.
-
assertEquals
public static void assertEquals(float expected, float actual, java.util.function.Supplier<java.lang.String> messageSupplier)
Asserts thatexpected
andactual
are equal.Equality imposed by this method is consistent with
Float.equals(Object)
andFloat.compare(float, float)
.If necessary, the failure message will be retrieved lazily from the supplied
messageSupplier
.
-
assertEquals
public static void assertEquals(float expected, float actual, float delta)
Asserts thatexpected
andactual
are equal within the givendelta
.Equality imposed by this method is consistent with
Float.equals(Object)
andFloat.compare(float, float)
.
-
assertEquals
public static void assertEquals(float expected, float actual, float delta, java.lang.String message)
Asserts thatexpected
andactual
are equal within the givendelta
.Equality imposed by this method is consistent with
Float.equals(Object)
andFloat.compare(float, float)
.
-
assertEquals
public static void assertEquals(float expected, float actual, float delta, java.util.function.Supplier<java.lang.String> messageSupplier)
Asserts thatexpected
andactual
are equal within the givendelta
.Equality imposed by this method is consistent with
Float.equals(Object)
andFloat.compare(float, float)
.If necessary, the failure message will be retrieved lazily from the supplied
messageSupplier
.
-
assertEquals
public static void assertEquals(double expected, double actual)
Asserts thatexpected
andactual
are equal.Equality imposed by this method is consistent with
Double.equals(Object)
andDouble.compare(double, double)
.
-
assertEquals
public static void assertEquals(double expected, double actual, java.lang.String message)
Asserts thatexpected
andactual
are equal.Equality imposed by this method is consistent with
Double.equals(Object)
andDouble.compare(double, double)
.
-
assertEquals
public static void assertEquals(double expected, double actual, java.util.function.Supplier<java.lang.String> messageSupplier)
Asserts thatexpected
andactual
are equal.Equality imposed by this method is consistent with
Double.equals(Object)
andDouble.compare(double, double)
.If necessary, the failure message will be retrieved lazily from the supplied
messageSupplier
.
-
assertEquals
public static void assertEquals(double expected, double actual, double delta)
Asserts thatexpected
andactual
are equal within the givendelta
.Equality imposed by this method is consistent with
Double.equals(Object)
andDouble.compare(double, double)
.
-
assertEquals
public static void assertEquals(double expected, double actual, double delta, java.lang.String message)
Asserts thatexpected
andactual
are equal within the givendelta
.Equality imposed by this method is consistent with
Double.equals(Object)
andDouble.compare(double, double)
.
-
assertEquals
public static void assertEquals(double expected, double actual, double delta, java.util.function.Supplier<java.lang.String> messageSupplier)
Asserts thatexpected
andactual
are equal within the givendelta
.Equality imposed by this method is consistent with
Double.equals(Object)
andDouble.compare(double, double)
.If necessary, the failure message will be retrieved lazily from the supplied
messageSupplier
.
-
assertEquals
public static void assertEquals(java.lang.Object expected, java.lang.Object actual)
Asserts thatexpected
andactual
are equal.If both are
null
, they are considered equal.- See Also:
Object.equals(Object)
-
assertEquals
public static void assertEquals(java.lang.Object expected, java.lang.Object actual, java.lang.String message)
Asserts thatexpected
andactual
are equal.If both are
null
, they are considered equal.Fails with the supplied failure
message
.- See Also:
Object.equals(Object)
-
assertEquals
public static void assertEquals(java.lang.Object expected, java.lang.Object actual, java.util.function.Supplier<java.lang.String> messageSupplier)
Asserts thatexpected
andactual
are equal.If both are
null
, they are considered equal.If necessary, the failure message will be retrieved lazily from the supplied
messageSupplier
.- See Also:
Object.equals(Object)
-
assertArrayEquals
public static void assertArrayEquals(boolean[] expected, boolean[] actual)
Asserts thatexpected
andactual
boolean arrays are equal.If both are
null
, they are considered equal.
-
assertArrayEquals
public static void assertArrayEquals(boolean[] expected, boolean[] actual, java.lang.String message)
Asserts thatexpected
andactual
boolean arrays are equal.If both are
null
, they are considered equal.Fails with the supplied failure
message
.
-
assertArrayEquals
public static void assertArrayEquals(boolean[] expected, boolean[] actual, java.util.function.Supplier<java.lang.String> messageSupplier)
Asserts thatexpected
andactual
boolean arrays are equal.If both are
null
, they are considered equal.If necessary, the failure message will be retrieved lazily from the supplied
messageSupplier
.
-
assertArrayEquals
public static void assertArrayEquals(char[] expected, char[] actual)
Asserts thatexpected
andactual
char arrays are equal.If both are
null
, they are considered equal.
-
assertArrayEquals
public static void assertArrayEquals(char[] expected, char[] actual, java.lang.String message)
Asserts thatexpected
andactual
char arrays are equal.If both are
null
, they are considered equal.Fails with the supplied failure
message
.
-
assertArrayEquals
public static void assertArrayEquals(char[] expected, char[] actual, java.util.function.Supplier<java.lang.String> messageSupplier)
Asserts thatexpected
andactual
char arrays are equal.If both are
null
, they are considered equal.If necessary, the failure message will be retrieved lazily from the supplied
messageSupplier
.
-
assertArrayEquals
public static void assertArrayEquals(byte[] expected, byte[] actual)
Asserts thatexpected
andactual
byte arrays are equal.If both are
null
, they are considered equal.
-
assertArrayEquals
public static void assertArrayEquals(byte[] expected, byte[] actual, java.lang.String message)
Asserts thatexpected
andactual
byte arrays are equal.If both are
null
, they are considered equal.Fails with the supplied failure
message
.
-
assertArrayEquals
public static void assertArrayEquals(byte[] expected, byte[] actual, java.util.function.Supplier<java.lang.String> messageSupplier)
Asserts thatexpected
andactual
byte arrays are equal.If both are
null
, they are considered equal.If necessary, the failure message will be retrieved lazily from the supplied
messageSupplier
.
-
assertArrayEquals
public static void assertArrayEquals(short[] expected, short[] actual)
Asserts thatexpected
andactual
short arrays are equal.If both are
null
, they are considered equal.
-
assertArrayEquals
public static void assertArrayEquals(short[] expected, short[] actual, java.lang.String message)
Asserts thatexpected
andactual
short arrays are equal.If both are
null
, they are considered equal.Fails with the supplied failure
message
.
-
assertArrayEquals
public static void assertArrayEquals(short[] expected, short[] actual, java.util.function.Supplier<java.lang.String> messageSupplier)
Asserts thatexpected
andactual
short arrays are equal.If both are
null
, they are considered equal.If necessary, the failure message will be retrieved lazily from the supplied
messageSupplier
.
-
assertArrayEquals
public static void assertArrayEquals(int[] expected, int[] actual)
Asserts thatexpected
andactual
int arrays are equal.If both are
null
, they are considered equal.
-
assertArrayEquals
public static void assertArrayEquals(int[] expected, int[] actual, java.lang.String message)
Asserts thatexpected
andactual
int arrays are equal.If both are
null
, they are considered equal.Fails with the supplied failure
message
.
-
assertArrayEquals
public static void assertArrayEquals(int[] expected, int[] actual, java.util.function.Supplier<java.lang.String> messageSupplier)
Asserts thatexpected
andactual
int arrays are equal.If both are
null
, they are considered equal.If necessary, the failure message will be retrieved lazily from the supplied
messageSupplier
.
-
assertArrayEquals
public static void assertArrayEquals(long[] expected, long[] actual)
Asserts thatexpected
andactual
long arrays are equal.If both are
null
, they are considered equal.
-
assertArrayEquals
public static void assertArrayEquals(long[] expected, long[] actual, java.lang.String message)
Asserts thatexpected
andactual
long arrays are equal.If both are
null
, they are considered equal.Fails with the supplied failure
message
.
-
assertArrayEquals
public static void assertArrayEquals(long[] expected, long[] actual, java.util.function.Supplier<java.lang.String> messageSupplier)
Asserts thatexpected
andactual
long arrays are equal.If both are
null
, they are considered equal.If necessary, the failure message will be retrieved lazily from the supplied
messageSupplier
.
-
assertArrayEquals
public static void assertArrayEquals(float[] expected, float[] actual)
Asserts thatexpected
andactual
float arrays are equal.Equality imposed by this method is consistent with
Float.equals(Object)
andFloat.compare(float, float)
.
-
assertArrayEquals
public static void assertArrayEquals(float[] expected, float[] actual, java.lang.String message)
Asserts thatexpected
andactual
float arrays are equal.Equality imposed by this method is consistent with
Float.equals(Object)
andFloat.compare(float, float)
.Fails with the supplied failure
message
.
-
assertArrayEquals
public static void assertArrayEquals(float[] expected, float[] actual, java.util.function.Supplier<java.lang.String> messageSupplier)
Asserts thatexpected
andactual
float arrays are equal.Equality imposed by this method is consistent with
Float.equals(Object)
andFloat.compare(float, float)
.If necessary, the failure message will be retrieved lazily from the supplied
messageSupplier
.
-
assertArrayEquals
public static void assertArrayEquals(float[] expected, float[] actual, float delta)
Asserts thatexpected
andactual
float arrays are equal within the givendelta
.Equality imposed by this method is consistent with
Float.equals(Object)
andFloat.compare(float, float)
.
-
assertArrayEquals
public static void assertArrayEquals(float[] expected, float[] actual, float delta, java.lang.String message)
Asserts thatexpected
andactual
float arrays are equal within the givendelta
.Equality imposed by this method is consistent with
Float.equals(Object)
andFloat.compare(float, float)
.Fails with the supplied failure
message
.
-
assertArrayEquals
public static void assertArrayEquals(float[] expected, float[] actual, float delta, java.util.function.Supplier<java.lang.String> messageSupplier)
Asserts thatexpected
andactual
float arrays are equal within the givendelta
.Equality imposed by this method is consistent with
Float.equals(Object)
andFloat.compare(float, float)
.If necessary, the failure message will be retrieved lazily from the supplied
messageSupplier
.
-
assertArrayEquals
public static void assertArrayEquals(double[] expected, double[] actual)
Asserts thatexpected
andactual
double arrays are equal.Equality imposed by this method is consistent with
Double.equals(Object)
andDouble.compare(double, double)
.
-
assertArrayEquals
public static void assertArrayEquals(double[] expected, double[] actual, java.lang.String message)
Asserts thatexpected
andactual
double arrays are equal.Equality imposed by this method is consistent with
Double.equals(Object)
andDouble.compare(double, double)
.Fails with the supplied failure
message
.
-
assertArrayEquals
public static void assertArrayEquals(double[] expected, double[] actual, java.util.function.Supplier<java.lang.String> messageSupplier)
Asserts thatexpected
andactual
double arrays are equal.Equality imposed by this method is consistent with
Double.equals(Object)
andDouble.compare(double, double)
.If necessary, the failure message will be retrieved lazily from the supplied
messageSupplier
.
-
assertArrayEquals
public static void assertArrayEquals(double[] expected, double[] actual, double delta)
Asserts thatexpected
andactual
double arrays are equal within the givendelta
.Equality imposed by this method is consistent with
Double.equals(Object)
andDouble.compare(double, double)
.
-
assertArrayEquals
public static void assertArrayEquals(double[] expected, double[] actual, double delta, java.lang.String message)
Asserts thatexpected
andactual
double arrays are equal within the givendelta
.Equality imposed by this method is consistent with
Double.equals(Object)
andDouble.compare(double, double)
.Fails with the supplied failure
message
.
-
assertArrayEquals
public static void assertArrayEquals(double[] expected, double[] actual, double delta, java.util.function.Supplier<java.lang.String> messageSupplier)
Asserts thatexpected
andactual
double arrays are equal within the givendelta
.Equality imposed by this method is consistent with
Double.equals(Object)
andDouble.compare(double, double)
.If necessary, the failure message will be retrieved lazily from the supplied
messageSupplier
.
-
assertArrayEquals
public static void assertArrayEquals(java.lang.Object[] expected, java.lang.Object[] actual)
Asserts thatexpected
andactual
object arrays are deeply equal.If both are
null
, they are considered equal.Nested float arrays are checked as in
assertEquals(float, float)
.Nested double arrays are checked as in
assertEquals(double, double)
.- See Also:
Objects.equals(Object, Object)
,Arrays.deepEquals(Object[], Object[])
-
assertArrayEquals
public static void assertArrayEquals(java.lang.Object[] expected, java.lang.Object[] actual, java.lang.String message)
Asserts thatexpected
andactual
object arrays are deeply equal.If both are
null
, they are considered equal.Nested float arrays are checked as in
assertEquals(float, float)
.Nested double arrays are checked as in
assertEquals(double, double)
.Fails with the supplied failure
message
.- See Also:
Objects.equals(Object, Object)
,Arrays.deepEquals(Object[], Object[])
-
assertArrayEquals
public static void assertArrayEquals(java.lang.Object[] expected, java.lang.Object[] actual, java.util.function.Supplier<java.lang.String> messageSupplier)
Asserts thatexpected
andactual
object arrays are deeply equal.If both are
null
, they are considered equal.Nested float arrays are checked as in
assertEquals(float, float)
.Nested double arrays are checked as in
assertEquals(double, double)
.If necessary, the failure message will be retrieved lazily from the supplied
messageSupplier
.- See Also:
Objects.equals(Object, Object)
,Arrays.deepEquals(Object[], Object[])
-
assertIterableEquals
public static void assertIterableEquals(java.lang.Iterable<?> expected, java.lang.Iterable<?> actual)
Asserts thatexpected
andactual
iterables are deeply equal.Similarly to the check for deep equality in
assertArrayEquals(Object[], Object[])
, if two iterables are encountered (includingexpected
andactual
) then their iterators must return equal elements in the same order as each other. Note: this means that the iterables do not need to be of the same type. Example:import static java.util.Arrays.asList; . . . Iterable<Integer> i0 = new ArrayList<>(asList(1, 2, 3)); Iterable<Integer> i1 = new LinkedList<>(asList(1, 2, 3)); assertIterableEquals(i0, i1); // Passes
If both
expected
andactual
arenull
, they are considered equal.- See Also:
Objects.equals(Object, Object)
,Arrays.deepEquals(Object[], Object[])
,assertArrayEquals(Object[], Object[])
-
assertIterableEquals
public static void assertIterableEquals(java.lang.Iterable<?> expected, java.lang.Iterable<?> actual, java.lang.String message)
Asserts thatexpected
andactual
iterables are deeply equal.Similarly to the check for deep equality in
assertArrayEquals(Object[], Object[], String)
, if two iterables are encountered (includingexpected
andactual
) then their iterators must return equal elements in the same order as each other. Note: this means that the iterables do not need to be of the same type. Example:import static java.util.Arrays.asList; . . . Iterable<Integer> i0 = new ArrayList<>(asList(1, 2, 3)); Iterable<Integer> i1 = new LinkedList<>(asList(1, 2, 3)); assertIterableEquals(i0, i1); // Passes
If both
expected
andactual
arenull
, they are considered equal.Fails with the supplied failure
message
.- See Also:
Objects.equals(Object, Object)
,Arrays.deepEquals(Object[], Object[])
,assertArrayEquals(Object[], Object[], String)
-
assertIterableEquals
public static void assertIterableEquals(java.lang.Iterable<?> expected, java.lang.Iterable<?> actual, java.util.function.Supplier<java.lang.String> messageSupplier)
Asserts thatexpected
andactual
iterables are deeply equal.Similarly to the check for deep equality in
assertArrayEquals(Object[], Object[], Supplier)
, if two iterables are encountered (includingexpected
andactual
) then their iterators must return equal elements in the same order as each other. Note: this means that the iterables do not need to be of the same type. Example:import static java.util.Arrays.asList; . . . Iterable<Integer> i0 = new ArrayList<>(asList(1, 2, 3)); Iterable<Integer> i1 = new LinkedList<>(asList(1, 2, 3)); assertIterableEquals(i0, i1); // Passes
If both
expected
andactual
arenull
, they are considered equal.If necessary, the failure message will be retrieved lazily from the supplied
messageSupplier
.- See Also:
Objects.equals(Object, Object)
,Arrays.deepEquals(Object[], Object[])
,assertArrayEquals(Object[], Object[], Supplier)
-
assertLinesMatch
public static void assertLinesMatch(java.util.List<java.lang.String> expectedLines, java.util.List<java.lang.String> actualLines)
Asserts thatexpected
list of Strings matchesactual
list.This method differs from other assertions that effectively only check
String.equals(Object)
, in that it uses the following staged matching algorithm:For each pair of expected and actual lines do
- check if
expected.equals(actual)
- if yes, continue with next pair - otherwise treat
expected
as a regular expression and check viaString.matches(String)
- if yes, continue with next pair - otherwise check if
expected
line is a fast-forward marker, if yes apply fast-forward actual lines accordingly (see below) and goto 1.
A valid fast-forward marker is an expected line that starts and ends with the literal
>>
and contains at least 4 characters. Examples:>>>>
>> stacktrace >>
>> single line, non Integer.parse()-able comment >>
Skip arbitrary number of actual lines, until first matching subsequent expected line is found. Any character between the fast-forward literals are discarded.">> 21 >>"
Skip strictly 21 lines. If they can't be skipped for any reason, an assertion error is raised.
Example showing all three kinds of expected line formats:
\u2502 \u2502 \u2502 caught: AssertionFailedError: single line fail message >> S T A C K T R A C E >> \u2502 \u2502 \u2502 duration: [\d]+ ms \u2502 \u2502 \u2502 status: \u2718 FAILED \u2502 \u2514\u2500 test() finished after [\d]+ ms\. \u2514\u2500 JUnit Jupiter finished after [\d]+ ms\. Test plan execution finished. Number of all tests: 1 Test run finished after [\d]+ ms
- check if
-
assertNotEquals
public static void assertNotEquals(java.lang.Object unexpected, java.lang.Object actual)
Asserts thatexpected
andactual
are not equal.Fails if both are
null
.- See Also:
Object.equals(Object)
-
assertNotEquals
public static void assertNotEquals(java.lang.Object unexpected, java.lang.Object actual, java.lang.String message)
Asserts thatexpected
andactual
are not equal.Fails if both are
null
.Fails with the supplied failure
message
.- See Also:
Object.equals(Object)
-
assertNotEquals
public static void assertNotEquals(java.lang.Object unexpected, java.lang.Object actual, java.util.function.Supplier<java.lang.String> messageSupplier)
Asserts thatexpected
andactual
are not equal.Fails if both are
null
.If necessary, the failure message will be retrieved lazily from the supplied
messageSupplier
.- See Also:
Object.equals(Object)
-
assertSame
public static void assertSame(java.lang.Object expected, java.lang.Object actual)
Asserts thatexpected
andactual
refer to the same object.
-
assertSame
public static void assertSame(java.lang.Object expected, java.lang.Object actual, java.lang.String message)
Asserts thatexpected
andactual
refer to the same object.Fails with the supplied failure
message
.
-
assertSame
public static void assertSame(java.lang.Object expected, java.lang.Object actual, java.util.function.Supplier<java.lang.String> messageSupplier)
Asserts thatexpected
andactual
refer to the same object.If necessary, the failure message will be retrieved lazily from the supplied
messageSupplier
.
-
assertNotSame
public static void assertNotSame(java.lang.Object unexpected, java.lang.Object actual)
Asserts thatexpected
andactual
do not refer to the same object.
-
assertNotSame
public static void assertNotSame(java.lang.Object unexpected, java.lang.Object actual, java.lang.String message)
Asserts thatexpected
andactual
do not refer to the same object.Fails with the supplied failure
message
.
-
assertNotSame
public static void assertNotSame(java.lang.Object unexpected, java.lang.Object actual, java.util.function.Supplier<java.lang.String> messageSupplier)
Asserts thatexpected
andactual
do not refer to the same object.If necessary, the failure message will be retrieved lazily from the supplied
messageSupplier
.
-
assertAll
public static void assertAll(Executable... executables) throws org.opentest4j.MultipleFailuresError
Asserts that all suppliedexecutables
do not throw exceptions.See Javadoc for
assertAll(String, Stream)
for an explanation of this method's exception handling semantics.- Throws:
org.opentest4j.MultipleFailuresError
- See Also:
assertAll(String, Executable...)
,assertAll(Collection)
,assertAll(String, Collection)
,assertAll(Stream)
,assertAll(String, Stream)
-
assertAll
public static void assertAll(java.lang.String heading, Executable... executables) throws org.opentest4j.MultipleFailuresError
Asserts that all suppliedexecutables
do not throw exceptions.See Javadoc for
assertAll(String, Stream)
for an explanation of this method's exception handling semantics.- Throws:
org.opentest4j.MultipleFailuresError
- See Also:
assertAll(Executable...)
,assertAll(Collection)
,assertAll(Stream)
,assertAll(String, Collection)
,assertAll(String, Stream)
-
assertAll
public static void assertAll(java.util.Collection<Executable> executables) throws org.opentest4j.MultipleFailuresError
Asserts that all suppliedexecutables
do not throw exceptions.See Javadoc for
assertAll(String, Stream)
for an explanation of this method's exception handling semantics.- Throws:
org.opentest4j.MultipleFailuresError
- See Also:
assertAll(Executable...)
,assertAll(String, Executable...)
,assertAll(String, Collection)
,assertAll(Stream)
,assertAll(String, Stream)
-
assertAll
public static void assertAll(java.lang.String heading, java.util.Collection<Executable> executables) throws org.opentest4j.MultipleFailuresError
Asserts that all suppliedexecutables
do not throw exceptions.See Javadoc for
assertAll(String, Stream)
for an explanation of this method's exception handling semantics.- Throws:
org.opentest4j.MultipleFailuresError
- See Also:
assertAll(Executable...)
,assertAll(String, Executable...)
,assertAll(Collection)
,assertAll(Stream)
,assertAll(String, Stream)
-
assertAll
public static void assertAll(java.util.stream.Stream<Executable> executables) throws org.opentest4j.MultipleFailuresError
Asserts that all suppliedexecutables
do not throw exceptions.See Javadoc for
assertAll(String, Stream)
for an explanation of this method's exception handling semantics.- Throws:
org.opentest4j.MultipleFailuresError
- See Also:
assertAll(Executable...)
,assertAll(String, Executable...)
,assertAll(Collection)
,assertAll(String, Collection)
,assertAll(String, Stream)
-
assertAll
public static void assertAll(java.lang.String heading, java.util.stream.Stream<Executable> executables) throws org.opentest4j.MultipleFailuresError
Asserts that all suppliedexecutables
do not throw exceptions.If any supplied
Executable
throws an exception (i.e., aThrowable
or any subclass thereof), all remainingexecutables
will still be executed, and all exceptions will be aggregated and reported in aMultipleFailuresError
. However, if anexecutable
throws a blacklisted exception — for example, anOutOfMemoryError
— execution will halt immediately, and the blacklisted exception will be rethrown as is but masked as an unchecked exception.The supplied
heading
will be included in the message string for theMultipleFailuresError
.- Throws:
org.opentest4j.MultipleFailuresError
- See Also:
assertAll(Executable...)
,assertAll(String, Executable...)
,assertAll(Collection)
,assertAll(String, Collection)
,assertAll(Stream)
-
assertThrows
public static <T extends java.lang.Throwable> T assertThrows(java.lang.Class<T> expectedType, Executable executable)
Asserts that execution of the suppliedexecutable
throws an exception of theexpectedType
and returns the exception.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.
-
assertThrows
public static <T extends java.lang.Throwable> T assertThrows(java.lang.Class<T> expectedType, Executable executable, java.lang.String message)
Asserts that execution of the suppliedexecutable
throws an exception of theexpectedType
and returns the exception.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.
-
assertThrows
public static <T extends java.lang.Throwable> T assertThrows(java.lang.Class<T> expectedType, Executable executable, java.util.function.Supplier<java.lang.String> messageSupplier)
Asserts that execution of the suppliedexecutable
throws an exception of theexpectedType
and returns the exception.If no exception is thrown, or if an exception of a different type is thrown, this method will fail.
If necessary, the failure message will be retrieved lazily from the supplied
messageSupplier
.If you do not want to perform additional checks on the exception instance, simply ignore the return value.
-
assertTimeout
public static void assertTimeout(java.time.Duration timeout, Executable executable)
Asserts that execution of the suppliedexecutable
completes before the giventimeout
is exceeded.Note: the
executable
will be executed in the same thread as that of the calling code. Consequently, execution of theexecutable
will not be preemptively aborted if the timeout is exceeded.
-
assertTimeout
public static void assertTimeout(java.time.Duration timeout, Executable executable, java.lang.String message)
Asserts that execution of the suppliedexecutable
completes before the giventimeout
is exceeded.Note: the
executable
will be executed in the same thread as that of the calling code. Consequently, execution of theexecutable
will not be preemptively aborted if the timeout is exceeded.Fails with the supplied failure
message
.
-
assertTimeout
public static void assertTimeout(java.time.Duration timeout, Executable executable, java.util.function.Supplier<java.lang.String> messageSupplier)
Asserts that execution of the suppliedexecutable
completes before the giventimeout
is exceeded.Note: the
executable
will be executed in the same thread as that of the calling code. Consequently, execution of theexecutable
will not be preemptively aborted if the timeout is exceeded.If necessary, the failure message will be retrieved lazily from the supplied
messageSupplier
.
-
assertTimeout
public static <T> T assertTimeout(java.time.Duration timeout, ThrowingSupplier<T> supplier)
Asserts that execution of the suppliedsupplier
completes before the giventimeout
is exceeded.If the assertion passes then the
supplier
's result is returned.Note: the
supplier
will be executed in the same thread as that of the calling code. Consequently, execution of thesupplier
will not be preemptively aborted if the timeout is exceeded.
-
assertTimeout
public static <T> T assertTimeout(java.time.Duration timeout, ThrowingSupplier<T> supplier, java.lang.String message)
Asserts that execution of the suppliedsupplier
completes before the giventimeout
is exceeded.If the assertion passes then the
supplier
's result is returned.Note: the
supplier
will be executed in the same thread as that of the calling code. Consequently, execution of thesupplier
will not be preemptively aborted if the timeout is exceeded.Fails with the supplied failure
message
.
-
assertTimeout
public static <T> T assertTimeout(java.time.Duration timeout, ThrowingSupplier<T> supplier, java.util.function.Supplier<java.lang.String> messageSupplier)
Asserts that execution of the suppliedsupplier
completes before the giventimeout
is exceeded.If the assertion passes then the
supplier
's result is returned.Note: the
supplier
will be executed in the same thread as that of the calling code. Consequently, execution of thesupplier
will not be preemptively aborted if the timeout is exceeded.If necessary, the failure message will be retrieved lazily from the supplied
messageSupplier
.
-
assertTimeoutPreemptively
public static void assertTimeoutPreemptively(java.time.Duration timeout, Executable executable)
Asserts that execution of the suppliedexecutable
completes before the giventimeout
is exceeded.Note: the
executable
will be executed in a different thread than that of the calling code. Furthermore, execution of theexecutable
will be preemptively aborted if the timeout is exceeded.- See Also:
assertTimeoutPreemptively(Duration, Executable, String)
,assertTimeoutPreemptively(Duration, Executable, Supplier)
,assertTimeoutPreemptively(Duration, ThrowingSupplier)
,assertTimeoutPreemptively(Duration, ThrowingSupplier, String)
,assertTimeoutPreemptively(Duration, ThrowingSupplier, Supplier)
,assertTimeout(Duration, Executable)
-
assertTimeoutPreemptively
public static void assertTimeoutPreemptively(java.time.Duration timeout, Executable executable, java.lang.String message)
Asserts that execution of the suppliedexecutable
completes before the giventimeout
is exceeded.Note: the
executable
will be executed in a different thread than that of the calling code. Furthermore, execution of theexecutable
will be preemptively aborted if the timeout is exceeded.Fails with the supplied failure
message
.- See Also:
assertTimeoutPreemptively(Duration, Executable)
,assertTimeoutPreemptively(Duration, Executable, Supplier)
,assertTimeoutPreemptively(Duration, ThrowingSupplier)
,assertTimeoutPreemptively(Duration, ThrowingSupplier, String)
,assertTimeoutPreemptively(Duration, ThrowingSupplier, Supplier)
,assertTimeout(Duration, Executable, String)
-
assertTimeoutPreemptively
public static void assertTimeoutPreemptively(java.time.Duration timeout, Executable executable, java.util.function.Supplier<java.lang.String> messageSupplier)
Asserts that execution of the suppliedexecutable
completes before the giventimeout
is exceeded.Note: the
executable
will be executed in a different thread than that of the calling code. Furthermore, execution of theexecutable
will be preemptively aborted if the timeout is exceeded.If necessary, the failure message will be retrieved lazily from the supplied
messageSupplier
.- See Also:
assertTimeoutPreemptively(Duration, Executable)
,assertTimeoutPreemptively(Duration, Executable, String)
,assertTimeoutPreemptively(Duration, ThrowingSupplier)
,assertTimeoutPreemptively(Duration, ThrowingSupplier, String)
,assertTimeoutPreemptively(Duration, ThrowingSupplier, Supplier)
,assertTimeout(Duration, Executable, Supplier)
-
assertTimeoutPreemptively
public static <T> T assertTimeoutPreemptively(java.time.Duration timeout, ThrowingSupplier<T> supplier)
Asserts that execution of the suppliedsupplier
completes before the giventimeout
is exceeded.If the assertion passes then the
supplier
's result is returned.Note: the
supplier
will be executed in a different thread than that of the calling code. Furthermore, execution of thesupplier
will be preemptively aborted if the timeout is exceeded.- See Also:
assertTimeoutPreemptively(Duration, Executable)
,assertTimeoutPreemptively(Duration, Executable, String)
,assertTimeoutPreemptively(Duration, Executable, Supplier)
,assertTimeoutPreemptively(Duration, ThrowingSupplier, String)
,assertTimeoutPreemptively(Duration, ThrowingSupplier, Supplier)
,assertTimeout(Duration, Executable)
-
assertTimeoutPreemptively
public static <T> T assertTimeoutPreemptively(java.time.Duration timeout, ThrowingSupplier<T> supplier, java.lang.String message)
Asserts that execution of the suppliedsupplier
completes before the giventimeout
is exceeded.If the assertion passes then the
supplier
's result is returned.Note: the
supplier
will be executed in a different thread than that of the calling code. Furthermore, execution of thesupplier
will be preemptively aborted if the timeout is exceeded.Fails with the supplied failure
message
.- See Also:
assertTimeoutPreemptively(Duration, Executable)
,assertTimeoutPreemptively(Duration, Executable, String)
,assertTimeoutPreemptively(Duration, Executable, Supplier)
,assertTimeoutPreemptively(Duration, ThrowingSupplier)
,assertTimeoutPreemptively(Duration, ThrowingSupplier, Supplier)
,assertTimeout(Duration, Executable, String)
-
assertTimeoutPreemptively
public static <T> T assertTimeoutPreemptively(java.time.Duration timeout, ThrowingSupplier<T> supplier, java.util.function.Supplier<java.lang.String> messageSupplier)
Asserts that execution of the suppliedsupplier
completes before the giventimeout
is exceeded.If the assertion passes then the
supplier
's result is returned.Note: the
supplier
will be executed in a different thread than that of the calling code. Furthermore, execution of thesupplier
will be preemptively aborted if the timeout is exceeded.If necessary, the failure message will be retrieved lazily from the supplied
messageSupplier
.- See Also:
assertTimeoutPreemptively(Duration, Executable)
,assertTimeoutPreemptively(Duration, Executable, String)
,assertTimeoutPreemptively(Duration, Executable, Supplier)
,assertTimeoutPreemptively(Duration, ThrowingSupplier)
,assertTimeoutPreemptively(Duration, ThrowingSupplier, String)
,assertTimeout(Duration, Executable, Supplier)
-
-