@API(value=Maintained) public final class Assertions extends java.lang.Object
Assertions
is a collection of utility methods that support
asserting conditions in tests. A failed assertion will
always throw AssertionFailedError
or a subclass thereof.AssertionFailedError
,
Assumptions
Modifier and Type | Method and Description |
---|---|
static void |
assertAll(Executable... executables)
Asserts that all supplied
executables do not throw an
AssertionError . |
static void |
assertAll(java.lang.String heading,
Executable... executables)
Asserts that all supplied
executables do not throw an
AssertionError . |
static void |
assertArrayEquals(boolean[] expected,
boolean[] actual)
Asserts that
expected and actual boolean arrays are equal. |
static void |
assertArrayEquals(boolean[] expected,
boolean[] actual,
java.lang.String message)
Asserts that
expected and actual boolean arrays are equal. |
static void |
assertArrayEquals(boolean[] expected,
boolean[] actual,
java.util.function.Supplier<java.lang.String> messageSupplier)
Asserts that
expected and actual boolean arrays are equal. |
static void |
assertArrayEquals(byte[] expected,
byte[] actual)
Asserts that
expected and actual byte arrays are equal. |
static void |
assertArrayEquals(byte[] expected,
byte[] actual,
java.lang.String message)
Asserts that
expected and actual byte arrays are equal. |
static void |
assertArrayEquals(byte[] expected,
byte[] actual,
java.util.function.Supplier<java.lang.String> messageSupplier)
Asserts that
expected and actual byte arrays are equal. |
static void |
assertArrayEquals(char[] expected,
char[] actual)
Asserts that
expected and actual char arrays are equal. |
static void |
assertArrayEquals(char[] expected,
char[] actual,
java.lang.String message)
Asserts that
expected and actual char arrays are equal. |
static void |
assertArrayEquals(char[] expected,
char[] actual,
java.util.function.Supplier<java.lang.String> messageSupplier)
Asserts that
expected and actual char arrays are equal. |
static void |
assertArrayEquals(double[] expected,
double[] actual)
Asserts that
expected and actual double arrays are equal. |
static void |
assertArrayEquals(double[] expected,
double[] actual,
double delta)
Asserts that
expected and actual double arrays are equal within the given delta . |
static void |
assertArrayEquals(double[] expected,
double[] actual,
double delta,
java.lang.String message)
Asserts that
expected and actual double arrays are equal within the given delta . |
static void |
assertArrayEquals(double[] expected,
double[] actual,
double delta,
java.util.function.Supplier<java.lang.String> messageSupplier)
Asserts that
expected and actual double arrays are equal within the given delta . |
static void |
assertArrayEquals(double[] expected,
double[] actual,
java.lang.String message)
Asserts that
expected and actual double arrays are equal. |
static void |
assertArrayEquals(double[] expected,
double[] actual,
java.util.function.Supplier<java.lang.String> messageSupplier)
Asserts that
expected and actual double arrays are equal. |
static void |
assertArrayEquals(float[] expected,
float[] actual)
Asserts that
expected and actual float arrays are equal. |
static void |
assertArrayEquals(float[] expected,
float[] actual,
float delta)
Asserts that
expected and actual float arrays are equal within the given delta . |
static void |
assertArrayEquals(float[] expected,
float[] actual,
float delta,
java.lang.String message)
Asserts that
expected and actual float arrays are equal within the given delta . |
static void |
assertArrayEquals(float[] expected,
float[] actual,
float delta,
java.util.function.Supplier<java.lang.String> messageSupplier)
Asserts that
expected and actual float arrays are equal within the given delta . |
static void |
assertArrayEquals(float[] expected,
float[] actual,
java.lang.String message)
Asserts that
expected and actual float arrays are equal. |
static void |
assertArrayEquals(float[] expected,
float[] actual,
java.util.function.Supplier<java.lang.String> messageSupplier)
Asserts that
expected and actual float arrays are equal. |
static void |
assertArrayEquals(int[] expected,
int[] actual)
Asserts that
expected and actual int arrays are equal. |
static void |
assertArrayEquals(int[] expected,
int[] actual,
java.lang.String message)
Asserts that
expected and actual int arrays are equal. |
static void |
assertArrayEquals(int[] expected,
int[] actual,
java.util.function.Supplier<java.lang.String> messageSupplier)
Asserts that
expected and actual int arrays are equal. |
static void |
assertArrayEquals(long[] expected,
long[] actual)
Asserts that
expected and actual long arrays are equal. |
static void |
assertArrayEquals(long[] expected,
long[] actual,
java.lang.String message)
Asserts that
expected and actual long arrays are equal. |
static void |
assertArrayEquals(long[] expected,
long[] actual,
java.util.function.Supplier<java.lang.String> messageSupplier)
Asserts that
expected and actual long arrays are equal. |
static void |
assertArrayEquals(java.lang.Object[] expected,
java.lang.Object[] actual)
Asserts that
expected and actual object arrays are deeply equal. |
static void |
assertArrayEquals(java.lang.Object[] expected,
java.lang.Object[] actual,
java.lang.String message)
Asserts that
expected and actual 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 that
expected and actual object arrays are deeply equal. |
static void |
assertArrayEquals(short[] expected,
short[] actual)
Asserts that
expected and actual short arrays are equal. |
static void |
assertArrayEquals(short[] expected,
short[] actual,
java.lang.String message)
Asserts that
expected and actual short arrays are equal. |
static void |
assertArrayEquals(short[] expected,
short[] actual,
java.util.function.Supplier<java.lang.String> messageSupplier)
Asserts that
expected and actual short arrays are equal. |
static void |
assertEquals(byte expected,
byte actual)
Asserts that
expected and actual are equal. |
static void |
assertEquals(byte expected,
byte actual,
java.lang.String message)
Asserts that
expected and actual are equal. |
static void |
assertEquals(byte expected,
byte actual,
java.util.function.Supplier<java.lang.String> messageSupplier)
Asserts that
expected and actual are equal. |
static void |
assertEquals(char expected,
char actual)
Asserts that
expected and actual are equal. |
static void |
assertEquals(char expected,
char actual,
java.lang.String message)
Asserts that
expected and actual are equal. |
static void |
assertEquals(char expected,
char actual,
java.util.function.Supplier<java.lang.String> messageSupplier)
Asserts that
expected and actual are equal. |
static void |
assertEquals(double expected,
double actual)
Asserts that
expected and actual are equal. |
static void |
assertEquals(double expected,
double actual,
double delta)
Asserts that
expected and actual are equal within the given delta . |
static void |
assertEquals(double expected,
double actual,
double delta,
java.lang.String message)
Asserts that
expected and actual are equal within the given delta . |
static void |
assertEquals(double expected,
double actual,
double delta,
java.util.function.Supplier<java.lang.String> messageSupplier)
Asserts that
expected and actual are equal within the given delta . |
static void |
assertEquals(double expected,
double actual,
java.lang.String message)
Asserts that
expected and actual are equal. |
static void |
assertEquals(double expected,
double actual,
java.util.function.Supplier<java.lang.String> messageSupplier)
Asserts that
expected and actual are equal. |
static void |
assertEquals(float expected,
float actual)
Asserts that
expected and actual are equal. |
static void |
assertEquals(float expected,
float actual,
float delta)
Asserts that
expected and actual are equal within the given delta . |
static void |
assertEquals(float expected,
float actual,
float delta,
java.lang.String message)
Asserts that
expected and actual are equal within the given delta . |
static void |
assertEquals(float expected,
float actual,
float delta,
java.util.function.Supplier<java.lang.String> messageSupplier)
Asserts that
expected and actual are equal within the given delta . |
static void |
assertEquals(float expected,
float actual,
java.lang.String message)
Asserts that
expected and actual are equal. |
static void |
assertEquals(float expected,
float actual,
java.util.function.Supplier<java.lang.String> messageSupplier)
Asserts that
expected and actual are equal. |
static void |
assertEquals(int expected,
int actual)
Asserts that
expected and actual are equal. |
static void |
assertEquals(int expected,
int actual,
java.lang.String message)
Asserts that
expected and actual are equal. |
static void |
assertEquals(int expected,
int actual,
java.util.function.Supplier<java.lang.String> messageSupplier)
Asserts that
expected and actual are equal. |
static void |
assertEquals(long expected,
long actual)
Asserts that
expected and actual are equal. |
static void |
assertEquals(long expected,
long actual,
java.lang.String message)
Asserts that
expected and actual are equal. |
static void |
assertEquals(long expected,
long actual,
java.util.function.Supplier<java.lang.String> messageSupplier)
Asserts that
expected and actual are equal. |
static void |
assertEquals(java.lang.Object expected,
java.lang.Object actual)
Asserts that
expected and actual are equal. |
static void |
assertEquals(java.lang.Object expected,
java.lang.Object actual,
java.lang.String message)
Asserts that
expected and actual are equal. |
static void |
assertEquals(java.lang.Object expected,
java.lang.Object actual,
java.util.function.Supplier<java.lang.String> messageSupplier)
Asserts that
expected and actual are equal. |
static void |
assertEquals(short expected,
short actual)
Asserts that
expected and actual are equal. |
static void |
assertEquals(short expected,
short actual,
java.lang.String message)
Asserts that
expected and actual are equal. |
static void |
assertEquals(short expected,
short actual,
java.util.function.Supplier<java.lang.String> messageSupplier)
Asserts that
expected and actual are equal. |
static void |
assertFalse(boolean condition)
Asserts that the supplied
condition is not true . |
static void |
assertFalse(boolean condition,
java.lang.String message)
Asserts that the supplied
condition is not true . |
static void |
assertFalse(java.util.function.BooleanSupplier booleanSupplier)
Asserts that the boolean condition supplied by
booleanSupplier is not true . |
static void |
assertFalse(boolean condition,
java.util.function.Supplier<java.lang.String> messageSupplier)
Asserts that the supplied
condition is not true . |
static void |
assertFalse(java.util.function.BooleanSupplier booleanSupplier,
java.lang.String message)
Asserts that the boolean condition supplied by
booleanSupplier is not true . |
static void |
assertFalse(java.util.function.BooleanSupplier booleanSupplier,
java.util.function.Supplier<java.lang.String> messageSupplier)
Asserts that the boolean condition supplied by
booleanSupplier is not true . |
static void |
assertNotEquals(java.lang.Object unexpected,
java.lang.Object actual)
Asserts that
expected and actual are not equal. |
static void |
assertNotEquals(java.lang.Object unexpected,
java.lang.Object actual,
java.lang.String message)
Asserts that
expected and actual are not equal. |
static void |
assertNotEquals(java.lang.Object unexpected,
java.lang.Object actual,
java.util.function.Supplier<java.lang.String> messageSupplier)
Asserts that
expected and actual are not equal. |
static void |
assertNotNull(java.lang.Object actual)
Asserts that
actual is not null . |
static void |
assertNotNull(java.lang.Object actual,
java.lang.String message)
Asserts that
actual is not null . |
static void |
assertNotNull(java.lang.Object actual,
java.util.function.Supplier<java.lang.String> messageSupplier)
Asserts that
actual is not null . |
static void |
assertNotSame(java.lang.Object unexpected,
java.lang.Object actual)
Asserts that
expected and actual do not refer to the same object. |
static void |
assertNotSame(java.lang.Object unexpected,
java.lang.Object actual,
java.lang.String message)
Asserts that
expected and actual 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 that
expected and actual do not refer to the same object. |
static void |
assertNull(java.lang.Object actual)
Asserts that
actual is null . |
static void |
assertNull(java.lang.Object actual,
java.lang.String message)
Asserts that
actual is null . |
static void |
assertNull(java.lang.Object actual,
java.util.function.Supplier<java.lang.String> messageSupplier)
Asserts that
actual is null . |
static void |
assertSame(java.lang.Object expected,
java.lang.Object actual)
Asserts that
expected and actual refer to the same object. |
static void |
assertSame(java.lang.Object expected,
java.lang.Object actual,
java.lang.String message)
Asserts that
expected and actual 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 that
expected and actual refer to the same object. |
static void |
assertThrows(java.lang.Class<? extends java.lang.Throwable> expectedType,
Executable executable)
Asserts that execution of the supplied
executable throws
an exception of the expectedType . |
static void |
assertTrue(boolean condition)
Asserts that the supplied
condition is true . |
static void |
assertTrue(boolean condition,
java.lang.String message)
Asserts that the supplied
condition is true . |
static void |
assertTrue(java.util.function.BooleanSupplier booleanSupplier)
Asserts that the boolean condition supplied by
booleanSupplier is true . |
static void |
assertTrue(boolean condition,
java.util.function.Supplier<java.lang.String> messageSupplier)
Asserts that the supplied
condition is true . |
static void |
assertTrue(java.util.function.BooleanSupplier booleanSupplier,
java.lang.String message)
Asserts that the boolean condition supplied by
booleanSupplier is true . |
static void |
assertTrue(java.util.function.BooleanSupplier booleanSupplier,
java.util.function.Supplier<java.lang.String> messageSupplier)
Asserts that the boolean condition supplied by
booleanSupplier is true . |
static <T extends java.lang.Throwable> |
expectThrows(java.lang.Class<T> expectedType,
Executable executable)
Asserts that execution of the supplied
executable throws
an exception of the expectedType , and returns the exception. |
static void |
fail(java.lang.String message)
Fails a test with the given failure
message . |
static void |
fail(java.util.function.Supplier<java.lang.String> messageSupplier)
Fails a test with the failure message retrieved from the
given
messageSupplier . |
public static void fail(java.lang.String message)
message
.public static void fail(java.util.function.Supplier<java.lang.String> messageSupplier)
messageSupplier
.public static void assertTrue(boolean condition)
condition
is true
.public static void assertTrue(boolean condition, java.util.function.Supplier<java.lang.String> messageSupplier)
condition
is true
.
If necessary, the failure message will be retrieved lazily from the supplied messageSupplier
.
public static void assertTrue(java.util.function.BooleanSupplier booleanSupplier)
booleanSupplier
is true
.public static void assertTrue(java.util.function.BooleanSupplier booleanSupplier, java.lang.String message)
booleanSupplier
is true
.
Fails with the supplied failure message
.
public static void assertTrue(boolean condition, java.lang.String message)
condition
is true
.
Fails with the supplied failure message
.
public static void assertTrue(java.util.function.BooleanSupplier booleanSupplier, java.util.function.Supplier<java.lang.String> messageSupplier)
booleanSupplier
is true
.
If necessary, the failure message will be retrieved lazily from the supplied messageSupplier
.
public static void assertFalse(boolean condition)
condition
is not true
.public static void assertFalse(boolean condition, java.lang.String message)
condition
is not true
.
Fails with the supplied failure message
.
public static void assertFalse(boolean condition, java.util.function.Supplier<java.lang.String> messageSupplier)
condition
is not true
.
If necessary, the failure message will be retrieved lazily from the supplied messageSupplier
.
public static void assertFalse(java.util.function.BooleanSupplier booleanSupplier)
booleanSupplier
is not true
.public static void assertFalse(java.util.function.BooleanSupplier booleanSupplier, java.lang.String message)
booleanSupplier
is not true
.
Fails with the supplied failure message
.
public static void assertFalse(java.util.function.BooleanSupplier booleanSupplier, java.util.function.Supplier<java.lang.String> messageSupplier)
booleanSupplier
is not true
.
If necessary, the failure message will be retrieved lazily from the supplied messageSupplier
.
public static void assertNull(java.lang.Object actual)
actual
is null
.public static void assertNull(java.lang.Object actual, java.lang.String message)
actual
is null
.
Fails with the supplied failure message
.
public static void assertNull(java.lang.Object actual, java.util.function.Supplier<java.lang.String> messageSupplier)
actual
is null
.
If necessary, the failure message will be retrieved lazily from the supplied messageSupplier
.
public static void assertNotNull(java.lang.Object actual)
actual
is not null
.public static void assertNotNull(java.lang.Object actual, java.lang.String message)
actual
is not null
.
Fails with the supplied failure message
.
public static void assertNotNull(java.lang.Object actual, java.util.function.Supplier<java.lang.String> messageSupplier)
actual
is not null
.
If necessary, the failure message will be retrieved lazily from the supplied messageSupplier
.
public static void assertEquals(short expected, short actual)
expected
and actual
are equal.public static void assertEquals(short expected, short actual, java.lang.String message)
expected
and actual
are equal.public static void assertEquals(short expected, short actual, java.util.function.Supplier<java.lang.String> messageSupplier)
expected
and actual
are equal.
If necessary, the failure message will be retrieved lazily from the supplied messageSupplier
.
public static void assertEquals(byte expected, byte actual)
expected
and actual
are equal.public static void assertEquals(byte expected, byte actual, java.lang.String message)
expected
and actual
are equal.public static void assertEquals(byte expected, byte actual, java.util.function.Supplier<java.lang.String> messageSupplier)
expected
and actual
are equal.
If necessary, the failure message will be retrieved lazily from the supplied messageSupplier
.
public static void assertEquals(int expected, int actual)
expected
and actual
are equal.public static void assertEquals(int expected, int actual, java.lang.String message)
expected
and actual
are equal.public static void assertEquals(int expected, int actual, java.util.function.Supplier<java.lang.String> messageSupplier)
expected
and actual
are equal.
If necessary, the failure message will be retrieved lazily from the supplied messageSupplier
.
public static void assertEquals(long expected, long actual)
expected
and actual
are equal.public static void assertEquals(long expected, long actual, java.lang.String message)
expected
and actual
are equal.public static void assertEquals(long expected, long actual, java.util.function.Supplier<java.lang.String> messageSupplier)
expected
and actual
are equal.
If necessary, the failure message will be retrieved lazily from the supplied messageSupplier
.
public static void assertEquals(char expected, char actual)
expected
and actual
are equal.public static void assertEquals(char expected, char actual, java.lang.String message)
expected
and actual
are equal.public static void assertEquals(char expected, char actual, java.util.function.Supplier<java.lang.String> messageSupplier)
expected
and actual
are equal.
If necessary, the failure message will be retrieved lazily from the supplied messageSupplier
.
public static void assertEquals(float expected, float actual)
expected
and actual
are equal.
Equality imposed by this method is consistent with Float.equals(Object)
and
Float.compare(float, float)
.
public static void assertEquals(float expected, float actual, java.lang.String message)
expected
and actual
are equal.
Equality imposed by this method is consistent with Float.equals(Object)
and
Float.compare(float, float)
.
public static void assertEquals(float expected, float actual, java.util.function.Supplier<java.lang.String> messageSupplier)
expected
and actual
are equal.
Equality imposed by this method is consistent with Float.equals(Object)
and
Float.compare(float, float)
.
If necessary, the failure message will be retrieved lazily from the supplied messageSupplier
.
public static void assertEquals(float expected, float actual, float delta)
expected
and actual
are equal within the given delta
.
Equality imposed by this method is consistent with Float.equals(Object)
and
Float.compare(float, float)
.
public static void assertEquals(float expected, float actual, float delta, java.lang.String message)
expected
and actual
are equal within the given delta
.
Equality imposed by this method is consistent with Float.equals(Object)
and
Float.compare(float, float)
.
public static void assertEquals(float expected, float actual, float delta, java.util.function.Supplier<java.lang.String> messageSupplier)
expected
and actual
are equal within the given delta
.
Equality imposed by this method is consistent with Float.equals(Object)
and
Float.compare(float, float)
.
If necessary, the failure message will be retrieved lazily from the supplied messageSupplier
.
public static void assertEquals(double expected, double actual)
expected
and actual
are equal.
Equality imposed by this method is consistent with Double.equals(Object)
and
Double.compare(double, double)
.
public static void assertEquals(double expected, double actual, java.lang.String message)
expected
and actual
are equal.
Equality imposed by this method is consistent with Double.equals(Object)
and
Double.compare(double, double)
.
public static void assertEquals(double expected, double actual, java.util.function.Supplier<java.lang.String> messageSupplier)
expected
and actual
are equal.
Equality imposed by this method is consistent with Double.equals(Object)
and
Double.compare(double, double)
.
If necessary, the failure message will be retrieved lazily from the supplied messageSupplier
.
public static void assertEquals(double expected, double actual, double delta)
expected
and actual
are equal within the given delta
.
Equality imposed by this method is consistent with Double.equals(Object)
and
Double.compare(double, double)
.
public static void assertEquals(double expected, double actual, double delta, java.lang.String message)
expected
and actual
are equal within the given delta
.
Equality imposed by this method is consistent with Double.equals(Object)
and
Double.compare(double, double)
.
public static void assertEquals(double expected, double actual, double delta, java.util.function.Supplier<java.lang.String> messageSupplier)
expected
and actual
are equal within the given delta
.
Equality imposed by this method is consistent with Double.equals(Object)
and
Double.compare(double, double)
.
If necessary, the failure message will be retrieved lazily from the supplied messageSupplier
.
public static void assertEquals(java.lang.Object expected, java.lang.Object actual)
expected
and actual
are equal.
If both are null
, they are considered equal.
Object.equals(Object)
public static void assertEquals(java.lang.Object expected, java.lang.Object actual, java.lang.String message)
expected
and actual
are equal.
If both are null
, they are considered equal.
Fails with the supplied failure message
.
Object.equals(Object)
public static void assertEquals(java.lang.Object expected, java.lang.Object actual, java.util.function.Supplier<java.lang.String> messageSupplier)
expected
and actual
are equal.
If both are null
, they are considered equal.
If necessary, the failure message will be retrieved lazily from the supplied messageSupplier
.
Object.equals(Object)
public static void assertArrayEquals(boolean[] expected, boolean[] actual)
expected
and actual
boolean arrays are equal.
If both are null
, they are considered equal.
public static void assertArrayEquals(boolean[] expected, boolean[] actual, java.lang.String message)
expected
and actual
boolean arrays are equal.
If both are null
, they are considered equal.
Fails with the supplied failure message
.
public static void assertArrayEquals(boolean[] expected, boolean[] actual, java.util.function.Supplier<java.lang.String> messageSupplier)
expected
and actual
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
.
public static void assertArrayEquals(char[] expected, char[] actual)
expected
and actual
char arrays are equal.
If both are null
, they are considered equal.
public static void assertArrayEquals(char[] expected, char[] actual, java.lang.String message)
expected
and actual
char arrays are equal.
If both are null
, they are considered equal.
Fails with the supplied failure message
.
public static void assertArrayEquals(char[] expected, char[] actual, java.util.function.Supplier<java.lang.String> messageSupplier)
expected
and actual
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
.
public static void assertArrayEquals(byte[] expected, byte[] actual)
expected
and actual
byte arrays are equal.
If both are null
, they are considered equal.
public static void assertArrayEquals(byte[] expected, byte[] actual, java.lang.String message)
expected
and actual
byte arrays are equal.
If both are null
, they are considered equal.
Fails with the supplied failure message
.
public static void assertArrayEquals(byte[] expected, byte[] actual, java.util.function.Supplier<java.lang.String> messageSupplier)
expected
and actual
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
.
public static void assertArrayEquals(short[] expected, short[] actual)
expected
and actual
short arrays are equal.
If both are null
, they are considered equal.
public static void assertArrayEquals(short[] expected, short[] actual, java.lang.String message)
expected
and actual
short arrays are equal.
If both are null
, they are considered equal.
Fails with the supplied failure message
.
public static void assertArrayEquals(short[] expected, short[] actual, java.util.function.Supplier<java.lang.String> messageSupplier)
expected
and actual
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
.
public static void assertArrayEquals(int[] expected, int[] actual)
expected
and actual
int arrays are equal.
If both are null
, they are considered equal.
public static void assertArrayEquals(int[] expected, int[] actual, java.lang.String message)
expected
and actual
int arrays are equal.
If both are null
, they are considered equal.
Fails with the supplied failure message
.
public static void assertArrayEquals(int[] expected, int[] actual, java.util.function.Supplier<java.lang.String> messageSupplier)
expected
and actual
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
.
public static void assertArrayEquals(long[] expected, long[] actual)
expected
and actual
long arrays are equal.
If both are null
, they are considered equal.
public static void assertArrayEquals(long[] expected, long[] actual, java.lang.String message)
expected
and actual
long arrays are equal.
If both are null
, they are considered equal.
Fails with the supplied failure message
.
public static void assertArrayEquals(long[] expected, long[] actual, java.util.function.Supplier<java.lang.String> messageSupplier)
expected
and actual
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
.
public static void assertArrayEquals(float[] expected, float[] actual)
expected
and actual
float arrays are equal.
Equality imposed by this method is consistent with Float.equals(Object)
and
Float.compare(float, float)
.
public static void assertArrayEquals(float[] expected, float[] actual, java.lang.String message)
expected
and actual
float arrays are equal.
Equality imposed by this method is consistent with Float.equals(Object)
and
Float.compare(float, float)
.
Fails with the supplied failure message
.
public static void assertArrayEquals(float[] expected, float[] actual, java.util.function.Supplier<java.lang.String> messageSupplier)
expected
and actual
float arrays are equal.
Equality imposed by this method is consistent with Float.equals(Object)
and
Float.compare(float, float)
.
If necessary, the failure message will be retrieved lazily from the supplied messageSupplier
.
public static void assertArrayEquals(float[] expected, float[] actual, float delta)
expected
and actual
float arrays are equal within the given delta
.
Equality imposed by this method is consistent with Float.equals(Object)
and
Float.compare(float, float)
.
public static void assertArrayEquals(float[] expected, float[] actual, float delta, java.lang.String message)
expected
and actual
float arrays are equal within the given delta
.
Equality imposed by this method is consistent with Float.equals(Object)
and
Float.compare(float, float)
.
Fails with the supplied failure message
.
public static void assertArrayEquals(float[] expected, float[] actual, float delta, java.util.function.Supplier<java.lang.String> messageSupplier)
expected
and actual
float arrays are equal within the given delta
.
Equality imposed by this method is consistent with Float.equals(Object)
and
Float.compare(float, float)
.
If necessary, the failure message will be retrieved lazily from the supplied messageSupplier
.
public static void assertArrayEquals(double[] expected, double[] actual)
expected
and actual
double arrays are equal.
Equality imposed by this method is consistent with Double.equals(Object)
and
Double.compare(double, double)
.
public static void assertArrayEquals(double[] expected, double[] actual, java.lang.String message)
expected
and actual
double arrays are equal.
Equality imposed by this method is consistent with Double.equals(Object)
and
Double.compare(double, double)
.
Fails with the supplied failure message
.
public static void assertArrayEquals(double[] expected, double[] actual, java.util.function.Supplier<java.lang.String> messageSupplier)
expected
and actual
double arrays are equal.
Equality imposed by this method is consistent with Double.equals(Object)
and
Double.compare(double, double)
.
If necessary, the failure message will be retrieved lazily from the supplied messageSupplier
.
public static void assertArrayEquals(double[] expected, double[] actual, double delta)
expected
and actual
double arrays are equal within the given delta
.
Equality imposed by this method is consistent with Double.equals(Object)
and
Double.compare(double, double)
.
public static void assertArrayEquals(double[] expected, double[] actual, double delta, java.lang.String message)
expected
and actual
double arrays are equal within the given delta
.
Equality imposed by this method is consistent with Double.equals(Object)
and
Double.compare(double, double)
.
Fails with the supplied failure message
.
public static void assertArrayEquals(double[] expected, double[] actual, double delta, java.util.function.Supplier<java.lang.String> messageSupplier)
expected
and actual
double arrays are equal within the given delta
.
Equality imposed by this method is consistent with Double.equals(Object)
and
Double.compare(double, double)
.
If necessary, the failure message will be retrieved lazily from the supplied messageSupplier
.
public static void assertArrayEquals(java.lang.Object[] expected, java.lang.Object[] actual)
expected
and actual
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)
.
Objects.equals(Object, Object)
,
Arrays.deepEquals(Object[], Object[])
public static void assertArrayEquals(java.lang.Object[] expected, java.lang.Object[] actual, java.lang.String message)
expected
and actual
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
.
Objects.equals(Object, Object)
,
Arrays.deepEquals(Object[], Object[])
public static void assertArrayEquals(java.lang.Object[] expected, java.lang.Object[] actual, java.util.function.Supplier<java.lang.String> messageSupplier)
expected
and actual
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
.
Objects.equals(Object, Object)
,
Arrays.deepEquals(Object[], Object[])
public static void assertNotEquals(java.lang.Object unexpected, java.lang.Object actual)
expected
and actual
are not equal.
Fails if both are null
.
Object.equals(Object)
public static void assertNotEquals(java.lang.Object unexpected, java.lang.Object actual, java.lang.String message)
expected
and actual
are not equal.
Fails if both are null
.
Fails with the supplied failure message
.
Object.equals(Object)
public static void assertNotEquals(java.lang.Object unexpected, java.lang.Object actual, java.util.function.Supplier<java.lang.String> messageSupplier)
expected
and actual
are not equal.
Fails if both are null
.
If necessary, the failure message will be retrieved lazily from the supplied messageSupplier
.
Object.equals(Object)
public static void assertSame(java.lang.Object expected, java.lang.Object actual)
expected
and actual
refer to the same object.public static void assertSame(java.lang.Object expected, java.lang.Object actual, java.lang.String message)
expected
and actual
refer to the same object.
Fails with the supplied failure message
.
public static void assertSame(java.lang.Object expected, java.lang.Object actual, java.util.function.Supplier<java.lang.String> messageSupplier)
expected
and actual
refer to the same object.
If necessary, the failure message will be retrieved lazily from the supplied messageSupplier
.
public static void assertNotSame(java.lang.Object unexpected, java.lang.Object actual)
expected
and actual
do not refer to the same object.public static void assertNotSame(java.lang.Object unexpected, java.lang.Object actual, java.lang.String message)
expected
and actual
do not refer to the same object.
Fails with the supplied failure message
.
public static void assertNotSame(java.lang.Object unexpected, java.lang.Object actual, java.util.function.Supplier<java.lang.String> messageSupplier)
expected
and actual
do not refer to the same object.
If necessary, the failure message will be retrieved lazily from the supplied messageSupplier
.
@API(value=Experimental) public static void assertAll(Executable... executables) throws org.opentest4j.MultipleFailuresError
executables
do not throw an
AssertionError
.
If any supplied Executable
throws an AssertionError
, all remaining
executables
will still be executed, and all failures will be aggregated
and reported in a MultipleFailuresError
. However, if an executable
throws an exception that is not an AssertionError
, execution will halt
immediately, and the exception will be rethrown as is but
masked
as an unchecked exception.
org.opentest4j.MultipleFailuresError
assertAll(String, Executable...)
@API(value=Experimental) public static void assertAll(java.lang.String heading, Executable... executables) throws org.opentest4j.MultipleFailuresError
executables
do not throw an
AssertionError
.
If any supplied Executable
throws an AssertionError
, all remaining
executables
will still be executed, and all failures will be aggregated
and reported in a MultipleFailuresError
. However, if an executable
throws an exception that is not an AssertionError
, execution will halt
immediately, and the exception will be rethrown as is but
masked
as an unchecked exception.
The supplied heading
will be included in the message string for the
MultipleFailuresError
.
org.opentest4j.MultipleFailuresError
public static void assertThrows(java.lang.Class<? extends java.lang.Throwable> expectedType, Executable executable)
executable
throws
an exception of the expectedType
.
If no exception is thrown, or if an exception of a different type is thrown, this method will fail.
Use assertThrows(java.lang.Class<? extends java.lang.Throwable>, org.junit.jupiter.api.Executable)
if you do not want to perform additional checks on
the exception instance. Otherwise use expectThrows(java.lang.Class<T>, org.junit.jupiter.api.Executable)
.
public static <T extends java.lang.Throwable> T expectThrows(java.lang.Class<T> expectedType, Executable executable)
executable
throws
an exception of the expectedType
, and returns the exception.
If no exception is thrown or if an exception of a different type is thrown, this method will fail.
Use expectThrows(java.lang.Class<T>, org.junit.jupiter.api.Executable)
if you want to perform additional checks on the exception instance.
Otherwise use assertThrows(java.lang.Class<? extends java.lang.Throwable>, org.junit.jupiter.api.Executable)
.