Class Assertions
Assertions is a collection of utility methods that support asserting
conditions in tests.
Unless otherwise noted, a failed assertion will throw an
AssertionFailedError or a subclass thereof.
Object Equality
Assertion methods comparing two objects for equality, such as the
assertEquals(expected, actual) and assertNotEquals(unexpected, actual)
variants, are only intended to test equality for an (un-)expected value
and an actual value. They are not designed for testing whether a class correctly
implements Object.equals(Object). For example, assertEquals()
might immediately return true when provided the same object for the
expected and actual values, without calling equals(Object) at all.
Tests that aim to verify the equals(Object) implementation should instead
be written to explicitly verify the Object.equals(Object) contract by
using assertTrue() or assertFalse() — for example, assertTrue(expected.equals(actual)),
assertTrue(actual.equals(expected)), assertFalse(expected.equals(null)),
etc.
Kotlin Support
Additional Kotlin assertions can be
found as top-level functions in the org.junit.jupiter.api
package.
Preemptive Timeouts
The various assertTimeoutPreemptively() methods in this class
execute the provided callback (executable or supplier) in a
different thread than that of the calling code. If the timeout is exceeded,
an attempt will be made to preemptively abort execution of the callback by
interrupting the callback's thread. If the
callback's thread does not return when interrupted, the thread will continue
to run in the background after the assertTimeoutPreemptively() method
has returned.
Furthermore, the behavior of assertTimeoutPreemptively() methods
can lead to undesirable side effects if the code that is executed within the
callback relies on ThreadLocal storage. One common example of this is
the transactional testing support in the Spring Framework. Specifically, Spring's
testing support binds transaction state to the current thread (via a
ThreadLocal) before a test method is invoked. Consequently, if a
callback provided to assertTimeoutPreemptively() invokes Spring-managed
components that participate in transactions, any actions taken by those
components will not be rolled back with the test-managed transaction. On the
contrary, such actions will be committed to the persistent store (e.g.,
relational database) even though the test-managed transaction is rolled back.
Similar side effects may be encountered with other frameworks that rely on
ThreadLocal storage.
Extensibility
Although it is technically possible to extend this class, extension is strongly discouraged. The JUnit Team highly recommends that the methods defined in this class be used via static imports.
- Since:
- 5.0
- See Also:
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedProtected constructor allowing subclassing but not direct instantiation. -
Method Summary
Modifier and TypeMethodDescriptionstatic voidassertAll(@Nullable String heading, Collection<Executable> executables) Assert that all suppliedexecutablesdo not throw exceptions.static voidassertAll(@Nullable String heading, Stream<Executable> executables) Assert that all suppliedexecutablesdo not throw exceptions.static voidassertAll(@Nullable String heading, Executable... executables) Assert that all suppliedexecutablesdo not throw exceptions.static voidassertAll(Collection<Executable> executables) Assert that all suppliedexecutablesdo not throw exceptions.static voidassertAll(Stream<Executable> executables) Assert that all suppliedexecutablesdo not throw exceptions.static voidassertAll(Executable... executables) Assert that all suppliedexecutablesdo not throw exceptions.static voidassertArrayEquals(boolean @Nullable [] expected, boolean @Nullable [] actual) Assert thatexpectedandactualboolean arrays are equal.static voidassertArrayEquals(boolean @Nullable [] expected, boolean @Nullable [] actual, @Nullable String message) Assert thatexpectedandactualboolean arrays are equal.static voidassertArrayEquals(boolean @Nullable [] expected, boolean @Nullable [] actual, Supplier<@Nullable String> messageSupplier) Assert thatexpectedandactualboolean arrays are equal.static voidassertArrayEquals(byte @Nullable [] expected, byte @Nullable [] actual) Assert thatexpectedandactualbyte arrays are equal.static voidassertArrayEquals(byte @Nullable [] expected, byte @Nullable [] actual, @Nullable String message) Assert thatexpectedandactualbyte arrays are equal.static voidassertArrayEquals(byte @Nullable [] expected, byte @Nullable [] actual, Supplier<@Nullable String> messageSupplier) Assert thatexpectedandactualbyte arrays are equal.static voidassertArrayEquals(char @Nullable [] expected, char @Nullable [] actual) Assert thatexpectedandactualchar arrays are equal.static voidassertArrayEquals(char @Nullable [] expected, char @Nullable [] actual, @Nullable String message) Assert thatexpectedandactualchar arrays are equal.static voidassertArrayEquals(char @Nullable [] expected, char @Nullable [] actual, Supplier<@Nullable String> messageSupplier) Assert thatexpectedandactualchar arrays are equal.static voidassertArrayEquals(double @Nullable [] expected, double @Nullable [] actual) Assert thatexpectedandactualdouble arrays are equal.static voidassertArrayEquals(double @Nullable [] expected, double @Nullable [] actual, double delta) Assert thatexpectedandactualdouble arrays are equal within the given non-negativedelta.static voidassertArrayEquals(double @Nullable [] expected, double @Nullable [] actual, double delta, @Nullable String message) Assert thatexpectedandactualdouble arrays are equal within the given non-negativedelta.static voidassertArrayEquals(double @Nullable [] expected, double @Nullable [] actual, double delta, Supplier<@Nullable String> messageSupplier) Assert thatexpectedandactualdouble arrays are equal within the given non-negativedelta.static voidassertArrayEquals(double @Nullable [] expected, double @Nullable [] actual, @Nullable String message) Assert thatexpectedandactualdouble arrays are equal.static voidassertArrayEquals(double @Nullable [] expected, double @Nullable [] actual, Supplier<@Nullable String> messageSupplier) Assert thatexpectedandactualdouble arrays are equal.static voidassertArrayEquals(float @Nullable [] expected, float @Nullable [] actual) Assert thatexpectedandactualfloat arrays are equal.static voidassertArrayEquals(float @Nullable [] expected, float @Nullable [] actual, float delta) Assert thatexpectedandactualfloat arrays are equal within the given non-negativedelta.static voidassertArrayEquals(float @Nullable [] expected, float @Nullable [] actual, float delta, @Nullable String message) Assert thatexpectedandactualfloat arrays are equal within the given non-negativedelta.static voidassertArrayEquals(float @Nullable [] expected, float @Nullable [] actual, float delta, Supplier<@Nullable String> messageSupplier) Assert thatexpectedandactualfloat arrays are equal within the given non-negativedelta.static voidassertArrayEquals(float @Nullable [] expected, float @Nullable [] actual, @Nullable String message) Assert thatexpectedandactualfloat arrays are equal.static voidassertArrayEquals(float @Nullable [] expected, float @Nullable [] actual, Supplier<@Nullable String> messageSupplier) Assert thatexpectedandactualfloat arrays are equal.static voidassertArrayEquals(int @Nullable [] expected, int @Nullable [] actual) Assert thatexpectedandactualint arrays are equal.static voidassertArrayEquals(int @Nullable [] expected, int @Nullable [] actual, @Nullable String message) Assert thatexpectedandactualint arrays are equal.static voidassertArrayEquals(int @Nullable [] expected, int @Nullable [] actual, Supplier<@Nullable String> messageSupplier) Assert thatexpectedandactualint arrays are equal.static voidassertArrayEquals(long @Nullable [] expected, long @Nullable [] actual) Assert thatexpectedandactuallong arrays are equal.static voidassertArrayEquals(long @Nullable [] expected, long @Nullable [] actual, @Nullable String message) Assert thatexpectedandactuallong arrays are equal.static voidassertArrayEquals(long @Nullable [] expected, long @Nullable [] actual, Supplier<@Nullable String> messageSupplier) Assert thatexpectedandactuallong arrays are equal.static voidassertArrayEquals(short @Nullable [] expected, short @Nullable [] actual) Assert thatexpectedandactualshort arrays are equal.static voidassertArrayEquals(short @Nullable [] expected, short @Nullable [] actual, @Nullable String message) Assert thatexpectedandactualshort arrays are equal.static voidassertArrayEquals(short @Nullable [] expected, short @Nullable [] actual, Supplier<@Nullable String> messageSupplier) Assert thatexpectedandactualshort arrays are equal.static voidassertArrayEquals(@Nullable Object @Nullable [] expected, @Nullable Object @Nullable [] actual) Assert thatexpectedandactualobject arrays are deeply equal.static voidassertArrayEquals(@Nullable Object @Nullable [] expected, @Nullable Object @Nullable [] actual, @Nullable String message) Assert thatexpectedandactualobject arrays are deeply equal.static voidassertArrayEquals(@Nullable Object @Nullable [] expected, @Nullable Object @Nullable [] actual, Supplier<@Nullable String> messageSupplier) Assert thatexpectedandactualobject arrays are deeply equal.static voidassertDoesNotThrow(Executable executable) Assert that execution of the suppliedexecutabledoes not throw any kind of exception.static voidassertDoesNotThrow(Executable executable, @Nullable String message) Assert that execution of the suppliedexecutabledoes not throw any kind of exception.static voidassertDoesNotThrow(Executable executable, Supplier<@Nullable String> messageSupplier) Assert that execution of the suppliedexecutabledoes not throw any kind of exception.static <T extends @Nullable Object>
TassertDoesNotThrow(ThrowingSupplier<T> supplier) Assert that execution of the suppliedsupplierdoes not throw any kind of exception.static <T extends @Nullable Object>
TassertDoesNotThrow(ThrowingSupplier<T> supplier, @Nullable String message) Assert that execution of the suppliedsupplierdoes not throw any kind of exception.static <T extends @Nullable Object>
TassertDoesNotThrow(ThrowingSupplier<T> supplier, Supplier<@Nullable String> messageSupplier) Assert that execution of the suppliedsupplierdoes not throw any kind of exception.static voidassertEquals(byte expected, byte actual) Assert thatexpectedandactualare equal.static voidassertEquals(byte expected, byte actual, @Nullable String message) Assert thatexpectedandactualare equal.static voidassertEquals(byte expected, byte actual, Supplier<@Nullable String> messageSupplier) Assert thatexpectedandactualare equal.static voidassertEquals(byte expected, @Nullable Byte actual) Assert thatexpectedandactualare equal.static voidassertEquals(byte expected, @Nullable Byte actual, @Nullable String message) Assert thatexpectedandactualare equal.static voidassertEquals(byte expected, @Nullable Byte actual, Supplier<@Nullable String> messageSupplier) Assert thatexpectedandactualare equal.static voidassertEquals(char expected, char actual) Assert thatexpectedandactualare equal.static voidassertEquals(char expected, char actual, @Nullable String message) Assert thatexpectedandactualare equal.static voidassertEquals(char expected, char actual, Supplier<@Nullable String> messageSupplier) Assert thatexpectedandactualare equal.static voidassertEquals(char expected, @Nullable Character actual) Assert thatexpectedandactualare equal.static voidassertEquals(char expected, @Nullable Character actual, @Nullable String message) Assert thatexpectedandactualare equal.static voidassertEquals(char expected, @Nullable Character actual, Supplier<@Nullable String> messageSupplier) Assert thatexpectedandactualare equal.static voidassertEquals(double expected, double actual) Assert thatexpectedandactualare equal.static voidassertEquals(double expected, double actual, double delta) Assert thatexpectedandactualare equal within the given non-negativedelta.static voidassertEquals(double expected, double actual, double delta, @Nullable String message) Assert thatexpectedandactualare equal within the given non-negativedelta.static voidassertEquals(double expected, double actual, double delta, Supplier<@Nullable String> messageSupplier) Assert thatexpectedandactualare equal within the given non-negativedelta.static voidassertEquals(double expected, double actual, @Nullable String message) Assert thatexpectedandactualare equal.static voidassertEquals(double expected, double actual, Supplier<@Nullable String> messageSupplier) Assert thatexpectedandactualare equal.static voidassertEquals(double expected, @Nullable Double actual) Assert thatexpectedandactualare equal.static voidassertEquals(double expected, @Nullable Double actual, @Nullable String message) Assert thatexpectedandactualare equal.static voidassertEquals(double expected, @Nullable Double actual, Supplier<@Nullable String> messageSupplier) Assert thatexpectedandactualare equal.static voidassertEquals(float expected, float actual) Assert thatexpectedandactualare equal.static voidassertEquals(float expected, float actual, float delta) Assert thatexpectedandactualare equal within the given non-negativedelta.static voidassertEquals(float expected, float actual, float delta, @Nullable String message) Assert thatexpectedandactualare equal within the given non-negativedelta.static voidassertEquals(float expected, float actual, float delta, Supplier<@Nullable String> messageSupplier) Assert thatexpectedandactualare equal within the given non-negativedelta.static voidassertEquals(float expected, float actual, @Nullable String message) Assert thatexpectedandactualare equal.static voidassertEquals(float expected, float actual, Supplier<@Nullable String> messageSupplier) Assert thatexpectedandactualare equal.static voidassertEquals(float expected, @Nullable Float actual) Assert thatexpectedandactualare equal.static voidassertEquals(float expected, @Nullable Float actual, @Nullable String message) Assert thatexpectedandactualare equal.static voidassertEquals(float expected, @Nullable Float actual, Supplier<@Nullable String> messageSupplier) Assert thatexpectedandactualare equal.static voidassertEquals(int expected, int actual) Assert thatexpectedandactualare equal.static voidassertEquals(int expected, int actual, @Nullable String message) Assert thatexpectedandactualare equal.static voidassertEquals(int expected, int actual, Supplier<@Nullable String> messageSupplier) Assert thatexpectedandactualare equal.static voidassertEquals(int expected, @Nullable Integer actual) Assert thatexpectedandactualare equal.static voidassertEquals(int expected, @Nullable Integer actual, @Nullable String message) Assert thatexpectedandactualare equal.static voidassertEquals(int expected, @Nullable Integer actual, Supplier<@Nullable String> messageSupplier) Assert thatexpectedandactualare equal.static voidassertEquals(long expected, long actual) Assert thatexpectedandactualare equal.static voidassertEquals(long expected, long actual, @Nullable String message) Assert thatexpectedandactualare equal.static voidassertEquals(long expected, long actual, Supplier<@Nullable String> messageSupplier) Assert thatexpectedandactualare equal.static voidassertEquals(long expected, @Nullable Long actual) Assert thatexpectedandactualare equal.static voidassertEquals(long expected, @Nullable Long actual, @Nullable String message) Assert thatexpectedandactualare equal.static voidassertEquals(long expected, @Nullable Long actual, Supplier<@Nullable String> messageSupplier) Assert thatexpectedandactualare equal.static voidassertEquals(short expected, short actual) Assert thatexpectedandactualare equal.static voidassertEquals(short expected, short actual, @Nullable String message) Assert thatexpectedandactualare equal.static voidassertEquals(short expected, short actual, Supplier<@Nullable String> messageSupplier) Assert thatexpectedandactualare equal.static voidassertEquals(short expected, @Nullable Short actual) Assert thatexpectedandactualare equal.static voidassertEquals(short expected, @Nullable Short actual, @Nullable String message) Assert thatexpectedandactualare equal.static voidassertEquals(short expected, @Nullable Short actual, Supplier<@Nullable String> messageSupplier) Assert thatexpectedandactualare equal.static voidassertEquals(@Nullable Byte expected, byte actual) Assert thatexpectedandactualare equal.static voidassertEquals(@Nullable Byte expected, byte actual, @Nullable String message) Assert thatexpectedandactualare equal.static voidassertEquals(@Nullable Byte expected, byte actual, Supplier<@Nullable String> messageSupplier) Assert thatexpectedandactualare equal.static voidassertEquals(@Nullable Byte expected, @Nullable Byte actual) Assert thatexpectedandactualare equal.static voidassertEquals(@Nullable Byte expected, @Nullable Byte actual, @Nullable String message) Assert thatexpectedandactualare equal.static voidassertEquals(@Nullable Byte expected, @Nullable Byte actual, Supplier<@Nullable String> messageSupplier) Assert thatexpectedandactualare equal.static voidassertEquals(@Nullable Character expected, char actual) Assert thatexpectedandactualare equal.static voidassertEquals(@Nullable Character expected, char actual, @Nullable String message) Assert thatexpectedandactualare equal.static voidassertEquals(@Nullable Character expected, char actual, Supplier<@Nullable String> messageSupplier) Assert thatexpectedandactualare equal.static voidassertEquals(@Nullable Character expected, @Nullable Character actual) Assert thatexpectedandactualare equal.static voidassertEquals(@Nullable Character expected, @Nullable Character actual, @Nullable String message) Assert thatexpectedandactualare equal.static voidassertEquals(@Nullable Character expected, @Nullable Character actual, Supplier<@Nullable String> messageSupplier) Assert thatexpectedandactualare equal.static voidassertEquals(@Nullable Double expected, double actual) Assert thatexpectedandactualare equal.static voidassertEquals(@Nullable Double expected, double actual, @Nullable String message) Assert thatexpectedandactualare equal.static voidassertEquals(@Nullable Double expected, double actual, Supplier<@Nullable String> messageSupplier) Assert thatexpectedandactualare equal.static voidassertEquals(@Nullable Double expected, @Nullable Double actual) Assert thatexpectedandactualare equal.static voidassertEquals(@Nullable Double expected, @Nullable Double actual, @Nullable String message) Assert thatexpectedandactualare equal.static voidassertEquals(@Nullable Double expected, @Nullable Double actual, Supplier<@Nullable String> messageSupplier) Assert thatexpectedandactualare equal.static voidassertEquals(@Nullable Float expected, float actual) Assert thatexpectedandactualare equal.static voidassertEquals(@Nullable Float expected, float actual, @Nullable String message) Assert thatexpectedandactualare equal.static voidassertEquals(@Nullable Float expected, float actual, Supplier<@Nullable String> messageSupplier) Assert thatexpectedandactualare equal.static voidassertEquals(@Nullable Float expected, @Nullable Float actual) Assert thatexpectedandactualare equal.static voidassertEquals(@Nullable Float expected, @Nullable Float actual, @Nullable String message) Assert thatexpectedandactualare equal.static voidassertEquals(@Nullable Float expected, @Nullable Float actual, Supplier<@Nullable String> messageSupplier) Assert thatexpectedandactualare equal.static voidassertEquals(@Nullable Integer expected, int actual) Assert thatexpectedandactualare equal.static voidassertEquals(@Nullable Integer expected, int actual, @Nullable String message) Assert thatexpectedandactualare equal.static voidassertEquals(@Nullable Integer expected, int actual, Supplier<@Nullable String> messageSupplier) Assert thatexpectedandactualare equal.static voidassertEquals(@Nullable Integer expected, @Nullable Integer actual) Assert thatexpectedandactualare equal.static voidassertEquals(@Nullable Integer expected, @Nullable Integer actual, @Nullable String message) Assert thatexpectedandactualare equal.static voidassertEquals(@Nullable Integer expected, @Nullable Integer actual, Supplier<@Nullable String> messageSupplier) Assert thatexpectedandactualare equal.static voidassertEquals(@Nullable Long expected, long actual) Assert thatexpectedandactualare equal.static voidassertEquals(@Nullable Long expected, long actual, @Nullable String message) Assert thatexpectedandactualare equal.static voidassertEquals(@Nullable Long expected, long actual, Supplier<@Nullable String> messageSupplier) Assert thatexpectedandactualare equal.static voidassertEquals(@Nullable Long expected, @Nullable Long actual) Assert thatexpectedandactualare equal.static voidassertEquals(@Nullable Long expected, @Nullable Long actual, @Nullable String message) Assert thatexpectedandactualare equal.static voidassertEquals(@Nullable Long expected, @Nullable Long actual, Supplier<@Nullable String> messageSupplier) Assert thatexpectedandactualare equal.static voidassertEquals(@Nullable Object expected, @Nullable Object actual) Assert thatexpectedandactualare equal.static voidassertEquals(@Nullable Object expected, @Nullable Object actual, @Nullable String message) Assert thatexpectedandactualare equal.static voidassertEquals(@Nullable Object expected, @Nullable Object actual, Supplier<@Nullable String> messageSupplier) Assert thatexpectedandactualare equal.static voidassertEquals(@Nullable Short expected, short actual) Assert thatexpectedandactualare equal.static voidassertEquals(@Nullable Short expected, short actual, @Nullable String message) Assert thatexpectedandactualare equal.static voidassertEquals(@Nullable Short expected, short actual, Supplier<@Nullable String> messageSupplier) Assert thatexpectedandactualare equal.static voidassertEquals(@Nullable Short expected, @Nullable Short actual) Assert thatexpectedandactualare equal.static voidassertEquals(@Nullable Short expected, @Nullable Short actual, @Nullable String message) Assert thatexpectedandactualare equal.static voidassertEquals(@Nullable Short expected, @Nullable Short actual, Supplier<@Nullable String> messageSupplier) Assert thatexpectedandactualare equal.static voidassertFalse(boolean condition) Assert that the suppliedconditionisfalse.static voidassertFalse(boolean condition, @Nullable String message) Assert that the suppliedconditionisfalse.static voidassertFalse(boolean condition, Supplier<@Nullable String> messageSupplier) Assert that the suppliedconditionisfalse.static voidassertFalse(BooleanSupplier booleanSupplier) Assert that the boolean condition supplied bybooleanSupplierisfalse.static voidassertFalse(BooleanSupplier booleanSupplier, @Nullable String message) Assert that the boolean condition supplied bybooleanSupplierisfalse.static voidassertFalse(BooleanSupplier booleanSupplier, Supplier<@Nullable String> messageSupplier) Assert that the boolean condition supplied bybooleanSupplierisfalse.static <T> TassertInstanceOf(Class<T> expectedType, @Nullable Object actualValue) Assert that the suppliedactualValueis an instance of theexpectedType.static <T> TassertInstanceOf(Class<T> expectedType, @Nullable Object actualValue, @Nullable String message) Assert that the suppliedactualValueis an instance of theexpectedType.static <T> TassertInstanceOf(Class<T> expectedType, @Nullable Object actualValue, Supplier<@Nullable String> messageSupplier) Assert that the suppliedactualValueis an instance of theexpectedType.static voidassertIterableEquals(@Nullable Iterable<?> expected, @Nullable Iterable<?> actual) Assert thatexpectedandactualiterables are deeply equal.static voidassertIterableEquals(@Nullable Iterable<?> expected, @Nullable Iterable<?> actual, @Nullable String message) Assert thatexpectedandactualiterables are deeply equal.static voidassertIterableEquals(@Nullable Iterable<?> expected, @Nullable Iterable<?> actual, Supplier<@Nullable String> messageSupplier) Assert thatexpectedandactualiterables are deeply equal.static voidassertLinesMatch(List<String> expectedLines, List<String> actualLines) static voidstatic voidassertLinesMatch(List<String> expectedLines, List<String> actualLines, Supplier<@Nullable String> messageSupplier) static voidassertLinesMatch(Stream<String> expectedLines, Stream<String> actualLines) static voidassertLinesMatch(Stream<String> expectedLines, Stream<String> actualLines, @Nullable String message) static voidassertLinesMatch(Stream<String> expectedLines, Stream<String> actualLines, Supplier<@Nullable String> messageSupplier) static voidassertNotEquals(byte unexpected, byte actual) Assert thatunexpectedandactualare not equal.static voidassertNotEquals(byte unexpected, byte actual, @Nullable String message) Assert thatunexpectedandactualare not equal.static voidassertNotEquals(byte unexpected, byte actual, Supplier<@Nullable String> messageSupplier) Assert thatunexpectedandactualare not equal.static voidassertNotEquals(byte unexpected, @Nullable Byte actual) Assert thatunexpectedandactualare not equal.static voidassertNotEquals(byte unexpected, @Nullable Byte actual, @Nullable String message) Assert thatunexpectedandactualare not equal.static voidassertNotEquals(byte unexpected, @Nullable Byte actual, Supplier<@Nullable String> messageSupplier) Assert thatunexpectedandactualare not equal.static voidassertNotEquals(char unexpected, char actual) Assert thatunexpectedandactualare not equal.static voidassertNotEquals(char unexpected, char actual, @Nullable String message) Assert thatunexpectedandactualare not equal.static voidassertNotEquals(char unexpected, char actual, Supplier<@Nullable String> messageSupplier) Assert thatunexpectedandactualare not equal.static voidassertNotEquals(char unexpected, @Nullable Character actual) Assert thatunexpectedandactualare not equal.static voidassertNotEquals(char unexpected, @Nullable Character actual, @Nullable String message) Assert thatunexpectedandactualare not equal.static voidassertNotEquals(char unexpected, @Nullable Character actual, Supplier<@Nullable String> messageSupplier) Assert thatunexpectedandactualare not equal.static voidassertNotEquals(double unexpected, double actual) Assert thatunexpectedandactualare not equal.static voidassertNotEquals(double unexpected, double actual, double delta) Assert thatunexpectedandactualare not equal within the givendelta.static voidassertNotEquals(double unexpected, double actual, double delta, @Nullable String message) Assert thatunexpectedandactualare not equal within the givendelta.static voidassertNotEquals(double unexpected, double actual, double delta, Supplier<@Nullable String> messageSupplier) Assert thatunexpectedandactualare not equal within the givendelta.static voidassertNotEquals(double unexpected, double actual, @Nullable String message) Assert thatunexpectedandactualare not equal.static voidassertNotEquals(double unexpected, double actual, Supplier<@Nullable String> messageSupplier) Assert thatunexpectedandactualare not equal.static voidassertNotEquals(double unexpected, @Nullable Double actual) Assert thatunexpectedandactualare not equal.static voidassertNotEquals(double unexpected, @Nullable Double actual, @Nullable String message) Assert thatunexpectedandactualare not equal.static voidassertNotEquals(double unexpected, @Nullable Double actual, Supplier<@Nullable String> messageSupplier) Assert thatunexpectedandactualare not equal.static voidassertNotEquals(float unexpected, float actual) Assert thatunexpectedandactualare not equal.static voidassertNotEquals(float unexpected, float actual, float delta) Assert thatunexpectedandactualare not equal within the givendelta.static voidassertNotEquals(float unexpected, float actual, float delta, @Nullable String message) Assert thatunexpectedandactualare not equal within the givendelta.static voidassertNotEquals(float unexpected, float actual, float delta, Supplier<@Nullable String> messageSupplier) Assert thatunexpectedandactualare not equal within the givendelta.static voidassertNotEquals(float unexpected, float actual, @Nullable String message) Assert thatunexpectedandactualare not equal.static voidassertNotEquals(float unexpected, float actual, Supplier<@Nullable String> messageSupplier) Assert thatunexpectedandactualare not equal.static voidassertNotEquals(float unexpected, @Nullable Float actual) Assert thatunexpectedandactualare not equal.static voidassertNotEquals(float unexpected, @Nullable Float actual, @Nullable String message) Assert thatunexpectedandactualare not equal.static voidassertNotEquals(float unexpected, @Nullable Float actual, Supplier<@Nullable String> messageSupplier) Assert thatunexpectedandactualare not equal.static voidassertNotEquals(int unexpected, int actual) Assert thatunexpectedandactualare not equal.static voidassertNotEquals(int unexpected, int actual, @Nullable String message) Assert thatunexpectedandactualare not equal.static voidassertNotEquals(int unexpected, int actual, Supplier<@Nullable String> messageSupplier) Assert thatunexpectedandactualare not equal.static voidassertNotEquals(int unexpected, @Nullable Integer actual) Assert thatunexpectedandactualare not equal.static voidassertNotEquals(int unexpected, @Nullable Integer actual, @Nullable String message) Assert thatunexpectedandactualare not equal.static voidassertNotEquals(int unexpected, @Nullable Integer actual, Supplier<@Nullable String> messageSupplier) Assert thatunexpectedandactualare not equal.static voidassertNotEquals(long unexpected, long actual) Assert thatunexpectedandactualare not equal.static voidassertNotEquals(long unexpected, long actual, @Nullable String message) Assert thatunexpectedandactualare not equal.static voidassertNotEquals(long unexpected, long actual, Supplier<@Nullable String> messageSupplier) Assert thatunexpectedandactualare not equal.static voidassertNotEquals(long unexpected, @Nullable Long actual) Assert thatunexpectedandactualare not equal.static voidassertNotEquals(long unexpected, @Nullable Long actual, @Nullable String message) Assert thatunexpectedandactualare not equal.static voidassertNotEquals(long unexpected, @Nullable Long actual, Supplier<@Nullable String> messageSupplier) Assert thatunexpectedandactualare not equal.static voidassertNotEquals(short unexpected, short actual) Assert thatunexpectedandactualare not equal.static voidassertNotEquals(short unexpected, short actual, @Nullable String message) Assert thatunexpectedandactualare not equal.static voidassertNotEquals(short unexpected, short actual, Supplier<@Nullable String> messageSupplier) Assert thatunexpectedandactualare not equal.static voidassertNotEquals(short unexpected, @Nullable Short actual) Assert thatunexpectedandactualare not equal.static voidassertNotEquals(short unexpected, @Nullable Short actual, @Nullable String message) Assert thatunexpectedandactualare not equal.static voidassertNotEquals(short unexpected, @Nullable Short actual, Supplier<@Nullable String> messageSupplier) Assert thatunexpectedandactualare not equal.static voidassertNotEquals(@Nullable Byte unexpected, byte actual) Assert thatunexpectedandactualare not equal.static voidassertNotEquals(@Nullable Byte unexpected, byte actual, @Nullable String message) Assert thatunexpectedandactualare not equal.static voidassertNotEquals(@Nullable Byte unexpected, byte actual, Supplier<@Nullable String> messageSupplier) Assert thatunexpectedandactualare not equal.static voidassertNotEquals(@Nullable Byte unexpected, @Nullable Byte actual) Assert thatunexpectedandactualare not equal.static voidassertNotEquals(@Nullable Byte unexpected, @Nullable Byte actual, @Nullable String message) Assert thatunexpectedandactualare not equal.static voidassertNotEquals(@Nullable Byte unexpected, @Nullable Byte actual, Supplier<@Nullable String> messageSupplier) Assert thatunexpectedandactualare not equal.static voidassertNotEquals(@Nullable Character unexpected, char actual) Assert thatunexpectedandactualare not equal.static voidassertNotEquals(@Nullable Character unexpected, char actual, @Nullable String message) Assert thatunexpectedandactualare not equal.static voidassertNotEquals(@Nullable Character unexpected, char actual, Supplier<@Nullable String> messageSupplier) Assert thatunexpectedandactualare not equal.static voidassertNotEquals(@Nullable Character unexpected, @Nullable Character actual) Assert thatunexpectedandactualare not equal.static voidassertNotEquals(@Nullable Character unexpected, @Nullable Character actual, @Nullable String message) Assert thatunexpectedandactualare not equal.static voidassertNotEquals(@Nullable Character unexpected, @Nullable Character actual, Supplier<@Nullable String> messageSupplier) Assert thatunexpectedandactualare not equal.static voidassertNotEquals(@Nullable Double unexpected, double actual) Assert thatunexpectedandactualare not equal.static voidassertNotEquals(@Nullable Double unexpected, double actual, @Nullable String message) Assert thatunexpectedandactualare not equal.static voidassertNotEquals(@Nullable Double unexpected, double actual, Supplier<@Nullable String> messageSupplier) Assert thatunexpectedandactualare not equal.static voidassertNotEquals(@Nullable Double unexpected, @Nullable Double actual) Assert thatunexpectedandactualare not equal.static voidassertNotEquals(@Nullable Double unexpected, @Nullable Double actual, @Nullable String message) Assert thatunexpectedandactualare not equal.static voidassertNotEquals(@Nullable Double unexpected, @Nullable Double actual, Supplier<@Nullable String> messageSupplier) Assert thatunexpectedandactualare not equal.static voidassertNotEquals(@Nullable Float unexpected, float actual) Assert thatunexpectedandactualare not equal.static voidassertNotEquals(@Nullable Float unexpected, float actual, @Nullable String message) Assert thatunexpectedandactualare not equal.static voidassertNotEquals(@Nullable Float unexpected, float actual, Supplier<@Nullable String> messageSupplier) Assert thatunexpectedandactualare not equal.static voidassertNotEquals(@Nullable Float unexpected, @Nullable Float actual) Assert thatunexpectedandactualare not equal.static voidassertNotEquals(@Nullable Float unexpected, @Nullable Float actual, @Nullable String message) Assert thatunexpectedandactualare not equal.static voidassertNotEquals(@Nullable Float unexpected, @Nullable Float actual, Supplier<@Nullable String> messageSupplier) Assert thatunexpectedandactualare not equal.static voidassertNotEquals(@Nullable Integer unexpected, int actual) Assert thatunexpectedandactualare not equal.static voidassertNotEquals(@Nullable Integer unexpected, int actual, @Nullable String message) Assert thatunexpectedandactualare not equal.static voidassertNotEquals(@Nullable Integer unexpected, int actual, Supplier<@Nullable String> messageSupplier) Assert thatunexpectedandactualare not equal.static voidassertNotEquals(@Nullable Integer unexpected, @Nullable Integer actual) Assert thatunexpectedandactualare not equal.static voidassertNotEquals(@Nullable Integer unexpected, @Nullable Integer actual, @Nullable String message) Assert thatunexpectedandactualare not equal.static voidassertNotEquals(@Nullable Integer unexpected, @Nullable Integer actual, Supplier<@Nullable String> messageSupplier) Assert thatunexpectedandactualare not equal.static voidassertNotEquals(@Nullable Long unexpected, long actual) Assert thatunexpectedandactualare not equal.static voidassertNotEquals(@Nullable Long unexpected, long actual, @Nullable String message) Assert thatunexpectedandactualare not equal.static voidassertNotEquals(@Nullable Long unexpected, long actual, Supplier<@Nullable String> messageSupplier) Assert thatunexpectedandactualare not equal.static voidassertNotEquals(@Nullable Long unexpected, @Nullable Long actual) Assert thatunexpectedandactualare not equal.static voidassertNotEquals(@Nullable Long unexpected, @Nullable Long actual, @Nullable String message) Assert thatunexpectedandactualare not equal.static voidassertNotEquals(@Nullable Long unexpected, @Nullable Long actual, Supplier<@Nullable String> messageSupplier) Assert thatunexpectedandactualare not equal.static voidassertNotEquals(@Nullable Object unexpected, @Nullable Object actual) Assert thatunexpectedandactualare not equal.static voidassertNotEquals(@Nullable Object unexpected, @Nullable Object actual, @Nullable String message) Assert thatunexpectedandactualare not equal.static voidassertNotEquals(@Nullable Object unexpected, @Nullable Object actual, Supplier<@Nullable String> messageSupplier) Assert thatunexpectedandactualare not equal.static voidassertNotEquals(@Nullable Short unexpected, short actual) Assert thatunexpectedandactualare not equal.static voidassertNotEquals(@Nullable Short unexpected, short actual, @Nullable String message) Assert thatunexpectedandactualare not equal.static voidassertNotEquals(@Nullable Short unexpected, short actual, Supplier<@Nullable String> messageSupplier) Assert thatunexpectedandactualare not equal.static voidassertNotEquals(@Nullable Short unexpected, @Nullable Short actual) Assert thatunexpectedandactualare not equal.static voidassertNotEquals(@Nullable Short unexpected, @Nullable Short actual, @Nullable String message) Assert thatunexpectedandactualare not equal.static voidassertNotEquals(@Nullable Short unexpected, @Nullable Short actual, Supplier<@Nullable String> messageSupplier) Assert thatunexpectedandactualare not equal.static voidassertNotNull(@Nullable Object actual) Assert thatactualis notnull.static voidassertNotNull(@Nullable Object actual, @Nullable String message) Assert thatactualis notnull.static voidassertNotNull(@Nullable Object actual, Supplier<@Nullable String> messageSupplier) Assert thatactualis notnull.static voidassertNotSame(@Nullable Object unexpected, @Nullable Object actual) Assert that theunexpectedobject and theactualobject are not the same object.static voidassertNotSame(@Nullable Object unexpected, @Nullable Object actual, @Nullable String message) Assert that theunexpectedobject and theactualobject are not the same object.static voidassertNotSame(@Nullable Object unexpected, @Nullable Object actual, Supplier<@Nullable String> messageSupplier) Assert that theunexpectedobject and theactualobject are not the same object.static voidassertNull(@Nullable Object actual) Assert thatactualisnull.static voidassertNull(@Nullable Object actual, @Nullable String message) Assert thatactualisnull.static voidassertNull(@Nullable Object actual, Supplier<@Nullable String> messageSupplier) Assert thatactualisnull.static voidassertSame(@Nullable Object expected, @Nullable Object actual) Assert that theexpectedobject and theactualobject are the same object.static voidassertSame(@Nullable Object expected, @Nullable Object actual, @Nullable String message) Assert that theexpectedobject and theactualobject are the same object.static voidassertSame(@Nullable Object expected, @Nullable Object actual, Supplier<@Nullable String> messageSupplier) Assert that theexpectedobject and theactualobject are the same object.static <T extends Throwable>
TassertThrows(Class<T> expectedType, Executable executable) Assert that execution of the suppliedexecutablethrows an exception of theexpectedTypeand return the exception.static <T extends Throwable>
TassertThrows(Class<T> expectedType, Executable executable, @Nullable String message) Assert that execution of the suppliedexecutablethrows an exception of theexpectedTypeand return the exception.static <T extends Throwable>
TassertThrows(Class<T> expectedType, Executable executable, Supplier<@Nullable String> messageSupplier) Assert that execution of the suppliedexecutablethrows an exception of theexpectedTypeand return the exception.static <T extends Throwable>
TassertThrowsExactly(Class<T> expectedType, Executable executable) Assert that execution of the suppliedexecutablethrows an exception of exactly theexpectedTypeand return the exception.static <T extends Throwable>
TassertThrowsExactly(Class<T> expectedType, Executable executable, @Nullable String message) Assert that execution of the suppliedexecutablethrows an exception of exactly theexpectedTypeand return the exception.static <T extends Throwable>
TassertThrowsExactly(Class<T> expectedType, Executable executable, Supplier<@Nullable String> messageSupplier) Assert that execution of the suppliedexecutablethrows an exception of exactly theexpectedTypeand return the exception.static voidassertTimeout(Duration timeout, Executable executable) Assert that execution of the suppliedexecutablecompletes before the giventimeoutis exceeded.static voidassertTimeout(Duration timeout, Executable executable, @Nullable String message) Assert that execution of the suppliedexecutablecompletes before the giventimeoutis exceeded.static voidassertTimeout(Duration timeout, Executable executable, Supplier<@Nullable String> messageSupplier) Assert that execution of the suppliedexecutablecompletes before the giventimeoutis exceeded.static <T extends @Nullable Object>
TassertTimeout(Duration timeout, ThrowingSupplier<T> supplier) Assert that execution of the suppliedsuppliercompletes before the giventimeoutis exceeded.static <T extends @Nullable Object>
TassertTimeout(Duration timeout, ThrowingSupplier<T> supplier, @Nullable String message) Assert that execution of the suppliedsuppliercompletes before the giventimeoutis exceeded.static <T extends @Nullable Object>
TassertTimeout(Duration timeout, ThrowingSupplier<T> supplier, Supplier<@Nullable String> messageSupplier) Assert that execution of the suppliedsuppliercompletes before the giventimeoutis exceeded.static voidassertTimeoutPreemptively(Duration timeout, Executable executable) Assert that execution of the suppliedexecutablecompletes before the giventimeoutis exceeded.static voidassertTimeoutPreemptively(Duration timeout, Executable executable, @Nullable String message) Assert that execution of the suppliedexecutablecompletes before the giventimeoutis exceeded.static voidassertTimeoutPreemptively(Duration timeout, Executable executable, Supplier<@Nullable String> messageSupplier) Assert that execution of the suppliedexecutablecompletes before the giventimeoutis exceeded.static <T extends @Nullable Object>
TassertTimeoutPreemptively(Duration timeout, ThrowingSupplier<T> supplier) Assert that execution of the suppliedsuppliercompletes before the giventimeoutis exceeded.static <T extends @Nullable Object>
TassertTimeoutPreemptively(Duration timeout, ThrowingSupplier<T> supplier, @Nullable String message) Assert that execution of the suppliedsuppliercompletes before the giventimeoutis exceeded.static <T extends @Nullable Object>
TassertTimeoutPreemptively(Duration timeout, ThrowingSupplier<T> supplier, Supplier<@Nullable String> messageSupplier) Assert that execution of the suppliedsuppliercompletes before the giventimeoutis exceeded.static voidassertTrue(boolean condition) Assert that the suppliedconditionistrue.static voidassertTrue(boolean condition, @Nullable String message) Assert that the suppliedconditionistrue.static voidassertTrue(boolean condition, Supplier<@Nullable String> messageSupplier) Assert that the suppliedconditionistrue.static voidassertTrue(BooleanSupplier booleanSupplier) Assert that the boolean condition supplied bybooleanSupplieristrue.static voidassertTrue(BooleanSupplier booleanSupplier, @Nullable String message) Assert that the boolean condition supplied bybooleanSupplieristrue.static voidassertTrue(BooleanSupplier booleanSupplier, Supplier<@Nullable String> messageSupplier) Assert that the boolean condition supplied bybooleanSupplieristrue.static <V> Vfail()Fail the test without a failure message.static <V> VFail the test with the given failuremessage.static <V> VFail the test with the given failuremessageas well as the underlyingcause.static <V> VFail the test with the given underlyingcause.static <V> VFail the test with the failure message retrieved from the givenmessageSupplier.
-
Constructor Details
-
Assertions
@API(status=STABLE, since="5.3") protected Assertions()Protected constructor allowing subclassing but not direct instantiation.- Since:
- 5.3
-
-
Method Details
-
fail
@Contract(" -> fail") public static <V> V fail()Fail the test without a failure message.Although failing with an explicit failure message is recommended, this method may be useful when maintaining legacy code.
See Javadoc for
fail(String)for an explanation of this method's generic return typeV. -
fail
Fail the test with the given failuremessage.The generic return type
Vallows 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 anAssertionFailedErrorbefore 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
@Contract("_, _ -> fail") public static <V> V fail(@Nullable String message, @Nullable Throwable cause) Fail the test with the given failuremessageas well as the underlyingcause.See Javadoc for
fail(String)for an explanation of this method's generic return typeV. -
fail
Fail the test with the given underlyingcause.See Javadoc for
fail(String)for an explanation of this method's generic return typeV. -
fail
Fail the test with the failure message retrieved from the givenmessageSupplier.See Javadoc for
fail(String)for an explanation of this method's generic return typeV. -
assertTrue
@Contract("false -> fail") public static void assertTrue(boolean condition) Assert that the suppliedconditionistrue. -
assertTrue
-
assertTrue
Assert that the boolean condition supplied bybooleanSupplieristrue. -
assertTrue
Assert that the boolean condition supplied bybooleanSupplieristrue.Fails with the supplied failure
message. -
assertTrue
@Contract("false, _ -> fail") public static void assertTrue(boolean condition, @Nullable String message) Assert that the suppliedconditionistrue.Fails with the supplied failure
message. -
assertTrue
public static void assertTrue(BooleanSupplier booleanSupplier, Supplier<@Nullable String> messageSupplier) Assert that the boolean condition supplied bybooleanSupplieristrue.If necessary, the failure message will be retrieved lazily from the supplied
messageSupplier. -
assertFalse
@Contract("true -> fail") public static void assertFalse(boolean condition) Assert that the suppliedconditionisfalse. -
assertFalse
@Contract("true, _ -> fail") public static void assertFalse(boolean condition, @Nullable String message) Assert that the suppliedconditionisfalse.Fails with the supplied failure
message. -
assertFalse
-
assertFalse
Assert that the boolean condition supplied bybooleanSupplierisfalse. -
assertFalse
Assert that the boolean condition supplied bybooleanSupplierisfalse.Fails with the supplied failure
message. -
assertFalse
public static void assertFalse(BooleanSupplier booleanSupplier, Supplier<@Nullable String> messageSupplier) Assert that the boolean condition supplied bybooleanSupplierisfalse.If necessary, the failure message will be retrieved lazily from the supplied
messageSupplier. -
assertNull
Assert thatactualisnull. -
assertNull
-
assertNull
-
assertNotNull
Assert thatactualis notnull. -
assertNotNull
-
assertNotNull
-
assertEquals
public static void assertEquals(short expected, short actual) Assert thatexpectedandactualare equal. -
assertEquals
Assert thatexpectedandactualare equal. -
assertEquals
Assert thatexpectedandactualare equal. -
assertEquals
-
assertEquals
Assert thatexpectedandactualare equal.Fails with the supplied failure
message. -
assertEquals
-
assertEquals
-
assertEquals
-
assertEquals
-
assertEquals
-
assertEquals
-
assertEquals
@API(status=STABLE, since="5.4") public static void assertEquals(@Nullable Short expected, @Nullable Short actual, Supplier<@Nullable String> messageSupplier) Assert thatexpectedandactualare equal.If necessary, the failure message will be retrieved lazily from the supplied
messageSupplier.- Since:
- 5.4
-
assertEquals
public static void assertEquals(byte expected, byte actual) Assert thatexpectedandactualare equal. -
assertEquals
Assert thatexpectedandactualare equal. -
assertEquals
Assert thatexpectedandactualare equal. -
assertEquals
-
assertEquals
Assert thatexpectedandactualare equal.Fails with the supplied failure
message. -
assertEquals
-
assertEquals
-
assertEquals
-
assertEquals
-
assertEquals
-
assertEquals
-
assertEquals
@API(status=STABLE, since="5.4") public static void assertEquals(@Nullable Byte expected, @Nullable Byte actual, Supplier<@Nullable String> messageSupplier) Assert thatexpectedandactualare equal.If necessary, the failure message will be retrieved lazily from the supplied
messageSupplier.- Since:
- 5.4
-
assertEquals
public static void assertEquals(int expected, int actual) Assert thatexpectedandactualare equal. -
assertEquals
Assert thatexpectedandactualare equal. -
assertEquals
Assert thatexpectedandactualare equal. -
assertEquals
-
assertEquals
Assert thatexpectedandactualare equal.Fails with the supplied failure
message. -
assertEquals
-
assertEquals
-
assertEquals
-
assertEquals
-
assertEquals
-
assertEquals
-
assertEquals
@API(status=STABLE, since="5.4") public static void assertEquals(@Nullable Integer expected, @Nullable Integer actual, Supplier<@Nullable String> messageSupplier) Assert thatexpectedandactualare equal.If necessary, the failure message will be retrieved lazily from the supplied
messageSupplier.- Since:
- 5.4
-
assertEquals
public static void assertEquals(long expected, long actual) Assert thatexpectedandactualare equal. -
assertEquals
Assert thatexpectedandactualare equal. -
assertEquals
Assert thatexpectedandactualare equal. -
assertEquals
-
assertEquals
Assert thatexpectedandactualare equal.Fails with the supplied failure
message. -
assertEquals
-
assertEquals
-
assertEquals
-
assertEquals
-
assertEquals
-
assertEquals
-
assertEquals
@API(status=STABLE, since="5.4") public static void assertEquals(@Nullable Long expected, @Nullable Long actual, Supplier<@Nullable String> messageSupplier) Assert thatexpectedandactualare equal.If necessary, the failure message will be retrieved lazily from the supplied
messageSupplier.- Since:
- 5.4
-
assertEquals
public static void assertEquals(float expected, float actual) Assert thatexpectedandactualare equal.Equality imposed by this method is consistent with
Float.equals(Object)andFloat.compare(float, float). -
assertEquals
Assert thatexpectedandactualare equal.Equality imposed by this method is consistent with
Float.equals(Object)andFloat.compare(float, float). -
assertEquals
Assert thatexpectedandactualare equal.Equality imposed by this method is consistent with
Float.equals(Object)andFloat.compare(float, float). -
assertEquals
@API(status=STABLE, since="5.4") public static void assertEquals(@Nullable Float expected, @Nullable Float actual) Assert thatexpectedandactualare equal.Equality imposed by this method is consistent with
Float.equals(Object)andFloat.compare(float, float).- Since:
- 5.4
-
assertEquals
Assert thatexpectedandactualare equal.Equality imposed by this method is consistent with
Float.equals(Object)andFloat.compare(float, float).Fails with the supplied failure
message. -
assertEquals
Assert thatexpectedandactualare equal.Equality imposed by this method is consistent with
Float.equals(Object)andFloat.compare(float, float).Fails with the supplied failure
message. -
assertEquals
Assert thatexpectedandactualare equal.Equality imposed by this method is consistent with
Float.equals(Object)andFloat.compare(float, float).Fails with the supplied failure
message. -
assertEquals
@API(status=STABLE, since="5.4") public static void assertEquals(@Nullable Float expected, @Nullable Float actual, @Nullable String message) Assert thatexpectedandactualare equal.Equality imposed by this method is consistent with
Float.equals(Object)andFloat.compare(float, float).Fails with the supplied failure
message.- Since:
- 5.4
-
assertEquals
public static void assertEquals(float expected, float actual, Supplier<@Nullable String> messageSupplier) Assert thatexpectedandactualare 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, @Nullable Float actual, Supplier<@Nullable String> messageSupplier) Assert thatexpectedandactualare 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(@Nullable Float expected, float actual, Supplier<@Nullable String> messageSupplier) Assert thatexpectedandactualare 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
@API(status=STABLE, since="5.4") public static void assertEquals(@Nullable Float expected, @Nullable Float actual, Supplier<@Nullable String> messageSupplier) Assert thatexpectedandactualare 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.- Since:
- 5.4
-
assertEquals
public static void assertEquals(float expected, float actual, float delta) Assert thatexpectedandactualare equal within the given non-negativedelta.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, @Nullable String message) Assert thatexpectedandactualare equal within the given non-negativedelta.Equality imposed by this method is consistent with
Float.equals(Object)andFloat.compare(float, float).Fails with the supplied failure
message. -
assertEquals
public static void assertEquals(float expected, float actual, float delta, Supplier<@Nullable String> messageSupplier) Assert thatexpectedandactualare equal within the given non-negativedelta.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) Assert thatexpectedandactualare equal.Equality imposed by this method is consistent with
Double.equals(Object)andDouble.compare(double, double). -
assertEquals
Assert thatexpectedandactualare equal.Equality imposed by this method is consistent with
Double.equals(Object)andDouble.compare(double, double). -
assertEquals
Assert thatexpectedandactualare equal.Equality imposed by this method is consistent with
Double.equals(Object)andDouble.compare(double, double). -
assertEquals
@API(status=STABLE, since="5.4") public static void assertEquals(@Nullable Double expected, @Nullable Double actual) Assert thatexpectedandactualare equal.Equality imposed by this method is consistent with
Double.equals(Object)andDouble.compare(double, double).- Since:
- 5.4
-
assertEquals
Assert thatexpectedandactualare equal.Equality imposed by this method is consistent with
Double.equals(Object)andDouble.compare(double, double).Fails with the supplied failure
message. -
assertEquals
Assert thatexpectedandactualare equal.Equality imposed by this method is consistent with
Double.equals(Object)andDouble.compare(double, double).Fails with the supplied failure
message. -
assertEquals
Assert thatexpectedandactualare equal.Equality imposed by this method is consistent with
Double.equals(Object)andDouble.compare(double, double).Fails with the supplied failure
message. -
assertEquals
@API(status=STABLE, since="5.4") public static void assertEquals(@Nullable Double expected, @Nullable Double actual, @Nullable String message) Assert thatexpectedandactualare equal.Equality imposed by this method is consistent with
Double.equals(Object)andDouble.compare(double, double).Fails with the supplied failure
message.- Since:
- 5.4
-
assertEquals
public static void assertEquals(double expected, double actual, Supplier<@Nullable String> messageSupplier) Assert thatexpectedandactualare 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, @Nullable Double actual, Supplier<@Nullable String> messageSupplier) Assert thatexpectedandactualare 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(@Nullable Double expected, double actual, Supplier<@Nullable String> messageSupplier) Assert thatexpectedandactualare 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
@API(status=STABLE, since="5.4") public static void assertEquals(@Nullable Double expected, @Nullable Double actual, Supplier<@Nullable String> messageSupplier) Assert thatexpectedandactualare 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.- Since:
- 5.4
-
assertEquals
public static void assertEquals(double expected, double actual, double delta) Assert thatexpectedandactualare equal within the given non-negativedelta.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, @Nullable String message) Assert thatexpectedandactualare equal within the given non-negativedelta.Equality imposed by this method is consistent with
Double.equals(Object)andDouble.compare(double, double).Fails with the supplied failure
message. -
assertEquals
public static void assertEquals(double expected, double actual, double delta, Supplier<@Nullable String> messageSupplier) Assert thatexpectedandactualare equal within the given non-negativedelta.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(char expected, char actual) Assert thatexpectedandactualare equal. -
assertEquals
Assert thatexpectedandactualare equal. -
assertEquals
Assert thatexpectedandactualare equal. -
assertEquals
-
assertEquals
Assert thatexpectedandactualare equal.Fails with the supplied failure
message. -
assertEquals
-
assertEquals
-
assertEquals
-
assertEquals
-
assertEquals
-
assertEquals
-
assertEquals
@API(status=STABLE, since="5.4") public static void assertEquals(@Nullable Character expected, @Nullable Character actual, Supplier<@Nullable String> messageSupplier) Assert thatexpectedandactualare equal.If necessary, the failure message will be retrieved lazily from the supplied
messageSupplier.- Since:
- 5.4
-
assertEquals
-
assertEquals
-
assertEquals
public static void assertEquals(@Nullable Object expected, @Nullable Object actual, Supplier<@Nullable String> messageSupplier) Assert thatexpectedandactualare equal.If both are
null, they are considered equal.If necessary, the failure message will be retrieved lazily from the supplied
messageSupplier.- See Also:
-
assertArrayEquals
public static void assertArrayEquals(boolean @Nullable [] expected, boolean @Nullable [] actual) Assert thatexpectedandactualboolean arrays are equal.If both are
null, they are considered equal. -
assertArrayEquals
public static void assertArrayEquals(boolean @Nullable [] expected, boolean @Nullable [] actual, @Nullable String message) Assert thatexpectedandactualboolean arrays are equal.If both are
null, they are considered equal.Fails with the supplied failure
message. -
assertArrayEquals
public static void assertArrayEquals(boolean @Nullable [] expected, boolean @Nullable [] actual, Supplier<@Nullable String> messageSupplier) Assert thatexpectedandactualboolean 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 @Nullable [] expected, char @Nullable [] actual) Assert thatexpectedandactualchar arrays are equal.If both are
null, they are considered equal. -
assertArrayEquals
public static void assertArrayEquals(char @Nullable [] expected, char @Nullable [] actual, @Nullable String message) Assert thatexpectedandactualchar arrays are equal.If both are
null, they are considered equal.Fails with the supplied failure
message. -
assertArrayEquals
public static void assertArrayEquals(char @Nullable [] expected, char @Nullable [] actual, Supplier<@Nullable String> messageSupplier) Assert thatexpectedandactualchar 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 @Nullable [] expected, byte @Nullable [] actual) Assert thatexpectedandactualbyte arrays are equal.If both are
null, they are considered equal. -
assertArrayEquals
public static void assertArrayEquals(byte @Nullable [] expected, byte @Nullable [] actual, @Nullable String message) Assert thatexpectedandactualbyte arrays are equal.If both are
null, they are considered equal.Fails with the supplied failure
message. -
assertArrayEquals
public static void assertArrayEquals(byte @Nullable [] expected, byte @Nullable [] actual, Supplier<@Nullable String> messageSupplier) Assert thatexpectedandactualbyte 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 @Nullable [] expected, short @Nullable [] actual) Assert thatexpectedandactualshort arrays are equal.If both are
null, they are considered equal. -
assertArrayEquals
public static void assertArrayEquals(short @Nullable [] expected, short @Nullable [] actual, @Nullable String message) Assert thatexpectedandactualshort arrays are equal.If both are
null, they are considered equal.Fails with the supplied failure
message. -
assertArrayEquals
public static void assertArrayEquals(short @Nullable [] expected, short @Nullable [] actual, Supplier<@Nullable String> messageSupplier) Assert thatexpectedandactualshort 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 @Nullable [] expected, int @Nullable [] actual) Assert thatexpectedandactualint arrays are equal.If both are
null, they are considered equal. -
assertArrayEquals
public static void assertArrayEquals(int @Nullable [] expected, int @Nullable [] actual, @Nullable String message) Assert thatexpectedandactualint arrays are equal.If both are
null, they are considered equal.Fails with the supplied failure
message. -
assertArrayEquals
public static void assertArrayEquals(int @Nullable [] expected, int @Nullable [] actual, Supplier<@Nullable String> messageSupplier) Assert thatexpectedandactualint 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 @Nullable [] expected, long @Nullable [] actual) Assert thatexpectedandactuallong arrays are equal.If both are
null, they are considered equal. -
assertArrayEquals
public static void assertArrayEquals(long @Nullable [] expected, long @Nullable [] actual, @Nullable String message) Assert thatexpectedandactuallong arrays are equal.If both are
null, they are considered equal.Fails with the supplied failure
message. -
assertArrayEquals
public static void assertArrayEquals(long @Nullable [] expected, long @Nullable [] actual, Supplier<@Nullable String> messageSupplier) Assert thatexpectedandactuallong 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 @Nullable [] expected, float @Nullable [] actual) Assert thatexpectedandactualfloat arrays are equal.Equality imposed by this method is consistent with
Float.equals(Object)andFloat.compare(float, float). -
assertArrayEquals
public static void assertArrayEquals(float @Nullable [] expected, float @Nullable [] actual, @Nullable String message) Assert thatexpectedandactualfloat 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 @Nullable [] expected, float @Nullable [] actual, Supplier<@Nullable String> messageSupplier) Assert thatexpectedandactualfloat 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 @Nullable [] expected, float @Nullable [] actual, float delta) Assert thatexpectedandactualfloat arrays are equal within the given non-negativedelta.Equality imposed by this method is consistent with
Float.equals(Object)andFloat.compare(float, float). -
assertArrayEquals
public static void assertArrayEquals(float @Nullable [] expected, float @Nullable [] actual, float delta, @Nullable String message) Assert thatexpectedandactualfloat arrays are equal within the given non-negativedelta.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 @Nullable [] expected, float @Nullable [] actual, float delta, Supplier<@Nullable String> messageSupplier) Assert thatexpectedandactualfloat arrays are equal within the given non-negativedelta.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 @Nullable [] expected, double @Nullable [] actual) Assert thatexpectedandactualdouble arrays are equal.Equality imposed by this method is consistent with
Double.equals(Object)andDouble.compare(double, double). -
assertArrayEquals
public static void assertArrayEquals(double @Nullable [] expected, double @Nullable [] actual, @Nullable String message) Assert thatexpectedandactualdouble 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 @Nullable [] expected, double @Nullable [] actual, Supplier<@Nullable String> messageSupplier) Assert thatexpectedandactualdouble 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 @Nullable [] expected, double @Nullable [] actual, double delta) Assert thatexpectedandactualdouble arrays are equal within the given non-negativedelta.Equality imposed by this method is consistent with
Double.equals(Object)andDouble.compare(double, double). -
assertArrayEquals
public static void assertArrayEquals(double @Nullable [] expected, double @Nullable [] actual, double delta, @Nullable String message) Assert thatexpectedandactualdouble arrays are equal within the given non-negativedelta.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 @Nullable [] expected, double @Nullable [] actual, double delta, Supplier<@Nullable String> messageSupplier) Assert thatexpectedandactualdouble arrays are equal within the given non-negativedelta.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(@Nullable Object @Nullable [] expected, @Nullable Object @Nullable [] actual) Assert thatexpectedandactualobject 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:
-
assertArrayEquals
public static void assertArrayEquals(@Nullable Object @Nullable [] expected, @Nullable Object @Nullable [] actual, @Nullable String message) Assert thatexpectedandactualobject 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:
-
assertArrayEquals
public static void assertArrayEquals(@Nullable Object @Nullable [] expected, @Nullable Object @Nullable [] actual, Supplier<@Nullable String> messageSupplier) Assert thatexpectedandactualobject 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:
-
assertIterableEquals
public static void assertIterableEquals(@Nullable Iterable<?> expected, @Nullable Iterable<?> actual) Assert thatexpectedandactualiterables are deeply equal.Similarly to the check for deep equality in
assertArrayEquals(Object[], Object[]), if two iterables are encountered (includingexpectedandactual) 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); // PassesIf both
expectedandactualarenull, they are considered equal.- See Also:
-
assertIterableEquals
public static void assertIterableEquals(@Nullable Iterable<?> expected, @Nullable Iterable<?> actual, @Nullable String message) Assert thatexpectedandactualiterables are deeply equal.Similarly to the check for deep equality in
assertArrayEquals(Object[], Object[], String), if two iterables are encountered (includingexpectedandactual) 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); // PassesIf both
expectedandactualarenull, they are considered equal.Fails with the supplied failure
message.- See Also:
-
assertIterableEquals
public static void assertIterableEquals(@Nullable Iterable<?> expected, @Nullable Iterable<?> actual, Supplier<@Nullable String> messageSupplier) Assert thatexpectedandactualiterables are deeply equal.Similarly to the check for deep equality in
assertArrayEquals(Object[], Object[], Supplier), if two iterables are encountered (includingexpectedandactual) 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); // PassesIf both
expectedandactualarenull, they are considered equal.If necessary, the failure message will be retrieved lazily from the supplied
messageSupplier.- See Also:
-
assertLinesMatch
Assert thatexpectedlist of Strings matchesactuallist.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
expectedas a regular expression and check viaString.matches(String)- if yes, continue with next pair - otherwise check if
expectedline 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.
Here is an example showing all three kinds of expected line formats:
ls -la / total [\d]+ drwxr-xr-x 0 root root 512 Jan 1 1970 . drwxr-xr-x 0 root root 512 Jan 1 1970 .. drwxr-xr-x 0 root root 512 Apr 5 07:45 bin >> 4 >> -rwxr-xr-x 1 root root [\d]+ Jan 1 1970 init >> M A N Y M O R E E N T R I E S >> drwxr-xr-x 0 root root 512 Sep 22 2017 varFails with a generated failure message describing the difference.
- check if
-
assertLinesMatch
public static void assertLinesMatch(List<String> expectedLines, List<String> actualLines, @Nullable String message) Assert thatexpectedlist of Strings matchesactuallist.Find a detailed description of the matching algorithm in
assertLinesMatch(List, List).Fails with the supplied failure
messageand the generated message.- See Also:
-
assertLinesMatch
public static void assertLinesMatch(List<String> expectedLines, List<String> actualLines, Supplier<@Nullable String> messageSupplier) Assert thatexpectedlist of Strings matchesactuallist.Find a detailed description of the matching algorithm in
assertLinesMatch(List, List).If necessary, a custom failure message will be retrieved lazily from the supplied
messageSupplier. Fails with the custom failure message prepended to a generated failure message describing the difference.- See Also:
-
assertLinesMatch
Assert thatexpectedstream of Strings matchesactualstream.Find a detailed description of the matching algorithm in
assertLinesMatch(List, List).Note: An implementation of this method may consume all lines of both streams eagerly and delegate the evaluation to
assertLinesMatch(List, List).- Since:
- 5.7
- See Also:
-
assertLinesMatch
public static void assertLinesMatch(Stream<String> expectedLines, Stream<String> actualLines, @Nullable String message) Assert thatexpectedstream of Strings matchesactualstream.Find a detailed description of the matching algorithm in
assertLinesMatch(List, List).Fails with the supplied failure
messageand the generated message.Note: An implementation of this method may consume all lines of both streams eagerly and delegate the evaluation to
assertLinesMatch(List, List).- Since:
- 5.7
- See Also:
-
assertLinesMatch
public static void assertLinesMatch(Stream<String> expectedLines, Stream<String> actualLines, Supplier<@Nullable String> messageSupplier) Assert thatexpectedstream of Strings matchesactualstream.Find a detailed description of the matching algorithm in
assertLinesMatch(List, List).If necessary, a custom failure message will be retrieved lazily from the supplied
messageSupplier. Fails with the custom failure message prepended to a generated failure message describing the difference.Note: An implementation of this method may consume all lines of both streams eagerly and delegate the evaluation to
assertLinesMatch(List, List).- Since:
- 5.7
- See Also:
-
assertNotEquals
@API(status=STABLE, since="5.4") public static void assertNotEquals(byte unexpected, byte actual) Assert thatunexpectedandactualare not equal.- Since:
- 5.4
-
assertNotEquals
@API(status=STABLE, since="5.4") public static void assertNotEquals(byte unexpected, @Nullable Byte actual) Assert thatunexpectedandactualare not equal.- Since:
- 5.4
-
assertNotEquals
@API(status=STABLE, since="5.4") public static void assertNotEquals(@Nullable Byte unexpected, byte actual) Assert thatunexpectedandactualare not equal.- Since:
- 5.4
-
assertNotEquals
-
assertNotEquals
@API(status=STABLE, since="5.4") public static void assertNotEquals(byte unexpected, byte actual, @Nullable String message) Assert thatunexpectedandactualare not equal.Fails with the supplied failure
message.- Since:
- 5.4
-
assertNotEquals
-
assertNotEquals
-
assertNotEquals
-
assertNotEquals
-
assertNotEquals
@API(status=STABLE, since="5.4") public static void assertNotEquals(byte unexpected, @Nullable Byte actual, Supplier<@Nullable String> messageSupplier) Assert thatunexpectedandactualare not equal.If necessary, the failure message will be retrieved lazily from the supplied
messageSupplier.- Since:
- 5.4
-
assertNotEquals
@API(status=STABLE, since="5.4") public static void assertNotEquals(@Nullable Byte unexpected, byte actual, Supplier<@Nullable String> messageSupplier) Assert thatunexpectedandactualare not equal.If necessary, the failure message will be retrieved lazily from the supplied
messageSupplier.- Since:
- 5.4
-
assertNotEquals
@API(status=STABLE, since="5.4") public static void assertNotEquals(@Nullable Byte unexpected, @Nullable Byte actual, Supplier<@Nullable String> messageSupplier) Assert thatunexpectedandactualare not equal.If necessary, the failure message will be retrieved lazily from the supplied
messageSupplier.- Since:
- 5.4
-
assertNotEquals
@API(status=STABLE, since="5.4") public static void assertNotEquals(short unexpected, short actual) Assert thatunexpectedandactualare not equal.- Since:
- 5.4
-
assertNotEquals
@API(status=STABLE, since="5.4") public static void assertNotEquals(short unexpected, @Nullable Short actual) Assert thatunexpectedandactualare not equal.- Since:
- 5.4
-
assertNotEquals
@API(status=STABLE, since="5.4") public static void assertNotEquals(@Nullable Short unexpected, short actual) Assert thatunexpectedandactualare not equal.- Since:
- 5.4
-
assertNotEquals
-
assertNotEquals
@API(status=STABLE, since="5.4") public static void assertNotEquals(short unexpected, short actual, @Nullable String message) Assert thatunexpectedandactualare not equal.Fails with the supplied failure
message.- Since:
- 5.4
-
assertNotEquals
-
assertNotEquals
-
assertNotEquals
-
assertNotEquals
-
assertNotEquals
@API(status=STABLE, since="5.4") public static void assertNotEquals(short unexpected, @Nullable Short actual, Supplier<@Nullable String> messageSupplier) Assert thatunexpectedandactualare not equal.If necessary, the failure message will be retrieved lazily from the supplied
messageSupplier.- Since:
- 5.4
-
assertNotEquals
@API(status=STABLE, since="5.4") public static void assertNotEquals(@Nullable Short unexpected, short actual, Supplier<@Nullable String> messageSupplier) Assert thatunexpectedandactualare not equal.If necessary, the failure message will be retrieved lazily from the supplied
messageSupplier.- Since:
- 5.4
-
assertNotEquals
@API(status=STABLE, since="5.4") public static void assertNotEquals(@Nullable Short unexpected, @Nullable Short actual, Supplier<@Nullable String> messageSupplier) Assert thatunexpectedandactualare not equal.If necessary, the failure message will be retrieved lazily from the supplied
messageSupplier.- Since:
- 5.4
-
assertNotEquals
@API(status=STABLE, since="5.4") public static void assertNotEquals(int unexpected, int actual) Assert thatunexpectedandactualare not equal.- Since:
- 5.4
-
assertNotEquals
@API(status=STABLE, since="5.4") public static void assertNotEquals(int unexpected, @Nullable Integer actual) Assert thatunexpectedandactualare not equal.- Since:
- 5.4
-
assertNotEquals
@API(status=STABLE, since="5.4") public static void assertNotEquals(@Nullable Integer unexpected, int actual) Assert thatunexpectedandactualare not equal.- Since:
- 5.4
-
assertNotEquals
-
assertNotEquals
@API(status=STABLE, since="5.4") public static void assertNotEquals(int unexpected, int actual, @Nullable String message) Assert thatunexpectedandactualare not equal.Fails with the supplied failure
message.- Since:
- 5.4
-
assertNotEquals
-
assertNotEquals
-
assertNotEquals
-
assertNotEquals
-
assertNotEquals
@API(status=STABLE, since="5.4") public static void assertNotEquals(int unexpected, @Nullable Integer actual, Supplier<@Nullable String> messageSupplier) Assert thatunexpectedandactualare not equal.If necessary, the failure message will be retrieved lazily from the supplied
messageSupplier.- Since:
- 5.4
-
assertNotEquals
@API(status=STABLE, since="5.4") public static void assertNotEquals(@Nullable Integer unexpected, int actual, Supplier<@Nullable String> messageSupplier) Assert thatunexpectedandactualare not equal.If necessary, the failure message will be retrieved lazily from the supplied
messageSupplier.- Since:
- 5.4
-
assertNotEquals
@API(status=STABLE, since="5.4") public static void assertNotEquals(@Nullable Integer unexpected, @Nullable Integer actual, Supplier<@Nullable String> messageSupplier) Assert thatunexpectedandactualare not equal.If necessary, the failure message will be retrieved lazily from the supplied
messageSupplier.- Since:
- 5.4
-
assertNotEquals
@API(status=STABLE, since="5.4") public static void assertNotEquals(long unexpected, long actual) Assert thatunexpectedandactualare not equal.- Since:
- 5.4
-
assertNotEquals
@API(status=STABLE, since="5.4") public static void assertNotEquals(long unexpected, @Nullable Long actual) Assert thatunexpectedandactualare not equal.- Since:
- 5.4
-
assertNotEquals
@API(status=STABLE, since="5.4") public static void assertNotEquals(@Nullable Long unexpected, long actual) Assert thatunexpectedandactualare not equal.- Since:
- 5.4
-
assertNotEquals
-
assertNotEquals
@API(status=STABLE, since="5.4") public static void assertNotEquals(long unexpected, long actual, @Nullable String message) Assert thatunexpectedandactualare not equal.Fails with the supplied failure
message.- Since:
- 5.4
-
assertNotEquals
-
assertNotEquals
-
assertNotEquals
-
assertNotEquals
-
assertNotEquals
@API(status=STABLE, since="5.4") public static void assertNotEquals(long unexpected, @Nullable Long actual, Supplier<@Nullable String> messageSupplier) Assert thatunexpectedandactualare not equal.If necessary, the failure message will be retrieved lazily from the supplied
messageSupplier.- Since:
- 5.4
-
assertNotEquals
@API(status=STABLE, since="5.4") public static void assertNotEquals(@Nullable Long unexpected, long actual, Supplier<@Nullable String> messageSupplier) Assert thatunexpectedandactualare not equal.If necessary, the failure message will be retrieved lazily from the supplied
messageSupplier.- Since:
- 5.4
-
assertNotEquals
@API(status=STABLE, since="5.4") public static void assertNotEquals(@Nullable Long unexpected, @Nullable Long actual, Supplier<@Nullable String> messageSupplier) Assert thatunexpectedandactualare not equal.If necessary, the failure message will be retrieved lazily from the supplied
messageSupplier.- Since:
- 5.4
-
assertNotEquals
@API(status=STABLE, since="5.4") public static void assertNotEquals(float unexpected, float actual) Assert thatunexpectedandactualare not equal.Inequality imposed by this method is consistent with
Float.equals(Object)andFloat.compare(float, float).- Since:
- 5.4
-
assertNotEquals
@API(status=STABLE, since="5.4") public static void assertNotEquals(float unexpected, @Nullable Float actual) Assert thatunexpectedandactualare not equal.Inequality imposed by this method is consistent with
Float.equals(Object)andFloat.compare(float, float).- Since:
- 5.4
-
assertNotEquals
@API(status=STABLE, since="5.4") public static void assertNotEquals(@Nullable Float unexpected, float actual) Assert thatunexpectedandactualare not equal.Inequality imposed by this method is consistent with
Float.equals(Object)andFloat.compare(float, float).- Since:
- 5.4
-
assertNotEquals
@API(status=STABLE, since="5.4") public static void assertNotEquals(@Nullable Float unexpected, @Nullable Float actual) Assert thatunexpectedandactualare not equal.Inequality imposed by this method is consistent with
Float.equals(Object)andFloat.compare(float, float).- Since:
- 5.4
-
assertNotEquals
@API(status=STABLE, since="5.4") public static void assertNotEquals(float unexpected, float actual, @Nullable String message) Assert thatunexpectedandactualare not equal.Inequality imposed by this method is consistent with
Float.equals(Object)andFloat.compare(float, float).Fails with the supplied failure
message.- Since:
- 5.4
-
assertNotEquals
@API(status=STABLE, since="5.4") public static void assertNotEquals(float unexpected, @Nullable Float actual, @Nullable String message) Assert thatunexpectedandactualare not equal.Inequality imposed by this method is consistent with
Float.equals(Object)andFloat.compare(float, float).Fails with the supplied failure
message.- Since:
- 5.4
-
assertNotEquals
@API(status=STABLE, since="5.4") public static void assertNotEquals(@Nullable Float unexpected, float actual, @Nullable String message) Assert thatunexpectedandactualare not equal.Inequality imposed by this method is consistent with
Float.equals(Object)andFloat.compare(float, float).Fails with the supplied failure
message.- Since:
- 5.4
-
assertNotEquals
@API(status=STABLE, since="5.4") public static void assertNotEquals(@Nullable Float unexpected, @Nullable Float actual, @Nullable String message) Assert thatunexpectedandactualare not equal.Inequality imposed by this method is consistent with
Float.equals(Object)andFloat.compare(float, float).Fails with the supplied failure
message.- Since:
- 5.4
-
assertNotEquals
@API(status=STABLE, since="5.4") public static void assertNotEquals(float unexpected, float actual, Supplier<@Nullable String> messageSupplier) Assert thatunexpectedandactualare not equal.Inequality imposed by this method is consistent with
Float.equals(Object)andFloat.compare(float, float).- Since:
- 5.4
-
assertNotEquals
@API(status=STABLE, since="5.4") public static void assertNotEquals(float unexpected, @Nullable Float actual, Supplier<@Nullable String> messageSupplier) Assert thatunexpectedandactualare not equal.Inequality imposed by this method is consistent with
Float.equals(Object)andFloat.compare(float, float).- Since:
- 5.4
-
assertNotEquals
@API(status=STABLE, since="5.4") public static void assertNotEquals(@Nullable Float unexpected, float actual, Supplier<@Nullable String> messageSupplier) Assert thatunexpectedandactualare not equal.Inequality imposed by this method is consistent with
Float.equals(Object)andFloat.compare(float, float).- Since:
- 5.4
-
assertNotEquals
@API(status=STABLE, since="5.4") public static void assertNotEquals(@Nullable Float unexpected, @Nullable Float actual, Supplier<@Nullable String> messageSupplier) Assert thatunexpectedandactualare not equal.Inequality imposed by this method is consistent with
Float.equals(Object)andFloat.compare(float, float).- Since:
- 5.4
-
assertNotEquals
@API(status=STABLE, since="5.4") public static void assertNotEquals(float unexpected, float actual, float delta) Assert thatunexpectedandactualare not equal within the givendelta.Inequality imposed by this method is consistent with
Float.equals(Object)andFloat.compare(float, float).- Since:
- 5.4
-
assertNotEquals
@API(status=STABLE, since="5.4") public static void assertNotEquals(float unexpected, float actual, float delta, @Nullable String message) Assert thatunexpectedandactualare not equal within the givendelta.Inequality imposed by this method is consistent with
Float.equals(Object)andFloat.compare(float, float).Fails with the supplied failure
message.- Since:
- 5.4
-
assertNotEquals
@API(status=STABLE, since="5.4") public static void assertNotEquals(float unexpected, float actual, float delta, Supplier<@Nullable String> messageSupplier) Assert thatunexpectedandactualare not equal within the givendelta.Inequality imposed by this method is consistent with
Float.equals(Object)andFloat.compare(float, float).- Since:
- 5.4
-
assertNotEquals
@API(status=STABLE, since="5.4") public static void assertNotEquals(double unexpected, double actual) Assert thatunexpectedandactualare not equal.Inequality imposed by this method is consistent with
Double.equals(Object)andDouble.compare(double, double).- Since:
- 5.4
-
assertNotEquals
@API(status=STABLE, since="5.4") public static void assertNotEquals(double unexpected, @Nullable Double actual) Assert thatunexpectedandactualare not equal.Inequality imposed by this method is consistent with
Double.equals(Object)andDouble.compare(double, double).- Since:
- 5.4
-
assertNotEquals
@API(status=STABLE, since="5.4") public static void assertNotEquals(@Nullable Double unexpected, double actual) Assert thatunexpectedandactualare not equal.Inequality imposed by this method is consistent with
Double.equals(Object)andDouble.compare(double, double).- Since:
- 5.4
-
assertNotEquals
@API(status=STABLE, since="5.4") public static void assertNotEquals(@Nullable Double unexpected, @Nullable Double actual) Assert thatunexpectedandactualare not equal.Inequality imposed by this method is consistent with
Double.equals(Object)andDouble.compare(double, double).- Since:
- 5.4
-
assertNotEquals
@API(status=STABLE, since="5.4") public static void assertNotEquals(double unexpected, double actual, @Nullable String message) Assert thatunexpectedandactualare not equal.Inequality imposed by this method is consistent with
Double.equals(Object)andDouble.compare(double, double).Fails with the supplied failure
message.- Since:
- 5.4
-
assertNotEquals
@API(status=STABLE, since="5.4") public static void assertNotEquals(double unexpected, @Nullable Double actual, @Nullable String message) Assert thatunexpectedandactualare not equal.Inequality imposed by this method is consistent with
Double.equals(Object)andDouble.compare(double, double).Fails with the supplied failure
message.- Since:
- 5.4
-
assertNotEquals
@API(status=STABLE, since="5.4") public static void assertNotEquals(@Nullable Double unexpected, double actual, @Nullable String message) Assert thatunexpectedandactualare not equal.Inequality imposed by this method is consistent with
Double.equals(Object)andDouble.compare(double, double).Fails with the supplied failure
message.- Since:
- 5.4
-
assertNotEquals
@API(status=STABLE, since="5.4") public static void assertNotEquals(@Nullable Double unexpected, @Nullable Double actual, @Nullable String message) Assert thatunexpectedandactualare not equal.Inequality imposed by this method is consistent with
Double.equals(Object)andDouble.compare(double, double).Fails with the supplied failure
message.- Since:
- 5.4
-
assertNotEquals
@API(status=STABLE, since="5.4") public static void assertNotEquals(double unexpected, double actual, Supplier<@Nullable String> messageSupplier) Assert thatunexpectedandactualare not equal.Inequality imposed by this method is consistent with
Double.equals(Object)andDouble.compare(double, double).- Since:
- 5.4
-
assertNotEquals
@API(status=STABLE, since="5.4") public static void assertNotEquals(double unexpected, @Nullable Double actual, Supplier<@Nullable String> messageSupplier) Assert thatunexpectedandactualare not equal.Inequality imposed by this method is consistent with
Double.equals(Object)andDouble.compare(double, double).- Since:
- 5.4
-
assertNotEquals
@API(status=STABLE, since="5.4") public static void assertNotEquals(@Nullable Double unexpected, double actual, Supplier<@Nullable String> messageSupplier) Assert thatunexpectedandactualare not equal.Inequality imposed by this method is consistent with
Double.equals(Object)andDouble.compare(double, double).- Since:
- 5.4
-
assertNotEquals
@API(status=STABLE, since="5.4") public static void assertNotEquals(@Nullable Double unexpected, @Nullable Double actual, Supplier<@Nullable String> messageSupplier) Assert thatunexpectedandactualare not equal.Inequality imposed by this method is consistent with
Double.equals(Object)andDouble.compare(double, double).- Since:
- 5.4
-
assertNotEquals
@API(status=STABLE, since="5.4") public static void assertNotEquals(double unexpected, double actual, double delta) Assert thatunexpectedandactualare not equal within the givendelta.Inequality imposed by this method is consistent with
Double.equals(Object)andDouble.compare(double, double).- Since:
- 5.4
-
assertNotEquals
@API(status=STABLE, since="5.4") public static void assertNotEquals(double unexpected, double actual, double delta, @Nullable String message) Assert thatunexpectedandactualare not equal within the givendelta.Inequality imposed by this method is consistent with
Double.equals(Object)andDouble.compare(double, double).Fails with the supplied failure
message.- Since:
- 5.4
-
assertNotEquals
@API(status=STABLE, since="5.4") public static void assertNotEquals(double unexpected, double actual, double delta, Supplier<@Nullable String> messageSupplier) Assert thatunexpectedandactualare not equal within the givendelta.Inequality imposed by this method is consistent with
Double.equals(Object)andDouble.compare(double, double).- Since:
- 5.4
-
assertNotEquals
@API(status=STABLE, since="5.4") public static void assertNotEquals(char unexpected, char actual) Assert thatunexpectedandactualare not equal.- Since:
- 5.4
-
assertNotEquals
@API(status=STABLE, since="5.4") public static void assertNotEquals(char unexpected, @Nullable Character actual) Assert thatunexpectedandactualare not equal.- Since:
- 5.4
-
assertNotEquals
@API(status=STABLE, since="5.4") public static void assertNotEquals(@Nullable Character unexpected, char actual) Assert thatunexpectedandactualare not equal.- Since:
- 5.4
-
assertNotEquals
-
assertNotEquals
@API(status=STABLE, since="5.4") public static void assertNotEquals(char unexpected, char actual, @Nullable String message) Assert thatunexpectedandactualare not equal.Fails with the supplied failure
message.- Since:
- 5.4
-
assertNotEquals
-
assertNotEquals
-
assertNotEquals
-
assertNotEquals
-
assertNotEquals
@API(status=STABLE, since="5.4") public static void assertNotEquals(char unexpected, @Nullable Character actual, Supplier<@Nullable String> messageSupplier) Assert thatunexpectedandactualare not equal.If necessary, the failure message will be retrieved lazily from the supplied
messageSupplier.- Since:
- 5.4
-
assertNotEquals
@API(status=STABLE, since="5.4") public static void assertNotEquals(@Nullable Character unexpected, char actual, Supplier<@Nullable String> messageSupplier) Assert thatunexpectedandactualare not equal.If necessary, the failure message will be retrieved lazily from the supplied
messageSupplier.- Since:
- 5.4
-
assertNotEquals
@API(status=STABLE, since="5.4") public static void assertNotEquals(@Nullable Character unexpected, @Nullable Character actual, Supplier<@Nullable String> messageSupplier) Assert thatunexpectedandactualare not equal.If necessary, the failure message will be retrieved lazily from the supplied
messageSupplier.- Since:
- 5.4
-
assertNotEquals
-
assertNotEquals
-
assertNotEquals
public static void assertNotEquals(@Nullable Object unexpected, @Nullable Object actual, Supplier<@Nullable String> messageSupplier) Assert thatunexpectedandactualare not equal.Fails if both are
null.If necessary, the failure message will be retrieved lazily from the supplied
messageSupplier.- See Also:
-
assertSame
Assert that theexpectedobject and theactualobject are the same object.This method should only be used to assert identity between objects. To assert equality between two objects or two primitive values, use one of the
assertEquals(...)methods instead — for example, useassertEquals(999, 999)instead ofassertSame(999, 999). -
assertSame
public static void assertSame(@Nullable Object expected, @Nullable Object actual, @Nullable String message) Assert that theexpectedobject and theactualobject are the same object.This method should only be used to assert identity between objects. To assert equality between two objects or two primitive values, use one of the
assertEquals(...)methods instead — for example, useassertEquals(999, 999)instead ofassertSame(999, 999).Fails with the supplied failure
message. -
assertSame
public static void assertSame(@Nullable Object expected, @Nullable Object actual, Supplier<@Nullable String> messageSupplier) Assert that theexpectedobject and theactualobject are the same object.This method should only be used to assert identity between objects. To assert equality between two objects or two primitive values, use one of the
assertEquals(...)methods instead — for example, useassertEquals(999, 999)instead ofassertSame(999, 999).If necessary, the failure message will be retrieved lazily from the supplied
messageSupplier. -
assertNotSame
Assert that theunexpectedobject and theactualobject are not the same object.This method should only be used to compare the identity of two objects. To assert that two objects or two primitive values are not equal, use one of the
assertNotEquals(...)methods instead. -
assertNotSame
public static void assertNotSame(@Nullable Object unexpected, @Nullable Object actual, @Nullable String message) Assert that theunexpectedobject and theactualobject are not the same object.This method should only be used to compare the identity of two objects. To assert that two objects or two primitive values are not equal, use one of the
assertNotEquals(...)methods instead.Fails with the supplied failure
message. -
assertNotSame
public static void assertNotSame(@Nullable Object unexpected, @Nullable Object actual, Supplier<@Nullable String> messageSupplier) Assert that theunexpectedobject and theactualobject are not the same object.This method should only be used to compare the identity of two objects. To assert that two objects or two primitive values are not equal, use one of the
assertNotEquals(...)methods instead.If necessary, the failure message will be retrieved lazily from the supplied
messageSupplier. -
assertAll
Assert that all suppliedexecutablesdo 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
public static void assertAll(@Nullable String heading, Executable... executables) throws org.opentest4j.MultipleFailuresError Assert that all suppliedexecutablesdo 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
public static void assertAll(Collection<Executable> executables) throws org.opentest4j.MultipleFailuresError Assert that all suppliedexecutablesdo 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
public static void assertAll(@Nullable String heading, Collection<Executable> executables) throws org.opentest4j.MultipleFailuresError Assert that all suppliedexecutablesdo 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
public static void assertAll(Stream<Executable> executables) throws org.opentest4j.MultipleFailuresError Assert that all suppliedexecutablesdo 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
public static void assertAll(@Nullable String heading, Stream<Executable> executables) throws org.opentest4j.MultipleFailuresError Assert that all suppliedexecutablesdo not throw exceptions.If any supplied
Executablethrows an exception (i.e., aThrowableor any subclass thereof), all remainingexecutableswill still be executed, and all exceptions will be aggregated and reported in aMultipleFailuresError. In addition, all aggregated exceptions will be added as suppressed exceptions to theMultipleFailuresError. However, if one of theexecutablesthrows an unrecoverable exception — for example, anOutOfMemoryError— execution will halt immediately, and the unrecoverable exception will be rethrown as is but masked as an unchecked exception.The supplied
headingwill be included in the message string for theMultipleFailuresError.- Throws:
org.opentest4j.MultipleFailuresError- See Also:
-
assertThrowsExactly
@API(status=STABLE, since="5.10") public static <T extends Throwable> T assertThrowsExactly(Class<T> expectedType, Executable executable) Assert that execution of the suppliedexecutablethrows an exception of exactly theexpectedTypeand return 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, ignore the return value.
- Since:
- 5.8
-
assertThrowsExactly
@API(status=STABLE, since="5.10") public static <T extends Throwable> T assertThrowsExactly(Class<T> expectedType, Executable executable, @Nullable String message) Assert that execution of the suppliedexecutablethrows an exception of exactly theexpectedTypeand return 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, ignore the return value.
Fails with the supplied failure
message. Note that the suppliedmessageis not the expected message of the thrown exception. To assert the expected message of the thrown exception, you must use a separate, subsequent assertion against the exception returned from this method.- Since:
- 5.8
-
assertThrowsExactly
@API(status=STABLE, since="5.10") public static <T extends Throwable> T assertThrowsExactly(Class<T> expectedType, Executable executable, Supplier<@Nullable String> messageSupplier) Assert that execution of the suppliedexecutablethrows an exception of exactly theexpectedTypeand return 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. Note that the failure message is not the expected message of the thrown exception. To assert the expected message of the thrown exception, you must use a separate, subsequent assertion against the exception returned from this method.If you do not want to perform additional checks on the exception instance, ignore the return value.
- Since:
- 5.8
-
assertThrows
Assert that execution of the suppliedexecutablethrows an exception of theexpectedTypeand return the exception.The assertion passes if the thrown exception type is the same as
expectedTypeor a subtype thereof. To check for the exact thrown type useassertThrowsExactly. 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, ignore the return value.
- See Also:
-
assertThrows
public static <T extends Throwable> T assertThrows(Class<T> expectedType, Executable executable, @Nullable String message) Assert that execution of the suppliedexecutablethrows an exception of theexpectedTypeand return the exception.The assertion passes if the thrown exception type is the same as
expectedTypeor a subtype thereof. To check for the exact thrown type useassertThrowsExactly. 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, ignore the return value.
Fails with the supplied failure
message. Note that the suppliedmessageis not the expected message of the thrown exception. To assert the expected message of the thrown exception, you must use a separate, subsequent assertion against the exception returned from this method.- See Also:
-
assertThrows
public static <T extends Throwable> T assertThrows(Class<T> expectedType, Executable executable, Supplier<@Nullable String> messageSupplier) Assert that execution of the suppliedexecutablethrows an exception of theexpectedTypeand return the exception.The assertion passes if the thrown exception type is the same as
expectedTypeor a subtype thereof. To check for the exact thrown type useassertThrowsExactly. 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. Note that the failure message is not the expected message of the thrown exception. To assert the expected message of the thrown exception, you must use a separate, subsequent assertion against the exception returned from this method.If you do not want to perform additional checks on the exception instance, ignore the return value.
- See Also:
-
assertDoesNotThrow
Assert that execution of the suppliedexecutabledoes not throw any kind of exception.Usage Note
Although any exception thrown from a test method will cause the test to fail, there are certain use cases where it can be beneficial to explicitly assert that an exception is not thrown for a given code block within a test method.
- Since:
- 5.2
-
assertDoesNotThrow
@API(status=STABLE, since="5.2") public static void assertDoesNotThrow(Executable executable, @Nullable String message) Assert that execution of the suppliedexecutabledoes not throw any kind of exception.Usage Note
Although any exception thrown from a test method will cause the test to fail, there are certain use cases where it can be beneficial to explicitly assert that an exception is not thrown for a given code block within a test method.
Fails with the supplied failure
message.- Since:
- 5.2
-
assertDoesNotThrow
@API(status=STABLE, since="5.2") public static void assertDoesNotThrow(Executable executable, Supplier<@Nullable String> messageSupplier) Assert that execution of the suppliedexecutabledoes not throw any kind of exception.Usage Note
Although any exception thrown from a test method will cause the test to fail, there are certain use cases where it can be beneficial to explicitly assert that an exception is not thrown for a given code block within a test method.
If necessary, the failure message will be retrieved lazily from the supplied
messageSupplier.- Since:
- 5.2
-
assertDoesNotThrow
@API(status=STABLE, since="5.2") public static <T extends @Nullable Object> T assertDoesNotThrow(ThrowingSupplier<T> supplier) Assert that execution of the suppliedsupplierdoes not throw any kind of exception.If the assertion passes, the
supplier's result will be returned.Usage Note
Although any exception thrown from a test method will cause the test to fail, there are certain use cases where it can be beneficial to explicitly assert that an exception is not thrown for a given code block within a test method.
- Since:
- 5.2
-
assertDoesNotThrow
@API(status=STABLE, since="5.2") public static <T extends @Nullable Object> T assertDoesNotThrow(ThrowingSupplier<T> supplier, @Nullable String message) Assert that execution of the suppliedsupplierdoes not throw any kind of exception.If the assertion passes, the
supplier's result will be returned.Fails with the supplied failure
message.Usage Note
Although any exception thrown from a test method will cause the test to fail, there are certain use cases where it can be beneficial to explicitly assert that an exception is not thrown for a given code block within a test method.
- Since:
- 5.2
-
assertDoesNotThrow
@API(status=STABLE, since="5.2") public static <T extends @Nullable Object> T assertDoesNotThrow(ThrowingSupplier<T> supplier, Supplier<@Nullable String> messageSupplier) Assert that execution of the suppliedsupplierdoes not throw any kind of exception.If the assertion passes, the
supplier's result will be returned.If necessary, the failure message will be retrieved lazily from the supplied
messageSupplier.Usage Note
Although any exception thrown from a test method will cause the test to fail, there are certain use cases where it can be beneficial to explicitly assert that an exception is not thrown for a given code block within a test method.
- Since:
- 5.2
-
assertTimeout
Assert that execution of the suppliedexecutablecompletes before the giventimeoutis exceeded.Note: the
executablewill be executed in the same thread as that of the calling code. Consequently, execution of theexecutablewill not be preemptively aborted if the timeout is exceeded.- See Also:
-
assertTimeout
Assert that execution of the suppliedexecutablecompletes before the giventimeoutis exceeded.Note: the
executablewill be executed in the same thread as that of the calling code. Consequently, execution of theexecutablewill not be preemptively aborted if the timeout is exceeded.Fails with the supplied failure
message.- See Also:
-
assertTimeout
public static void assertTimeout(Duration timeout, Executable executable, Supplier<@Nullable String> messageSupplier) Assert that execution of the suppliedexecutablecompletes before the giventimeoutis exceeded.Note: the
executablewill be executed in the same thread as that of the calling code. Consequently, execution of theexecutablewill not be preemptively aborted if the timeout is exceeded.If necessary, the failure message will be retrieved lazily from the supplied
messageSupplier.- See Also:
-
assertTimeout
public static <T extends @Nullable Object> T assertTimeout(Duration timeout, ThrowingSupplier<T> supplier) Assert that execution of the suppliedsuppliercompletes before the giventimeoutis exceeded.If the assertion passes then the
supplier's result is returned.Note: the
supplierwill be executed in the same thread as that of the calling code. Consequently, execution of thesupplierwill not be preemptively aborted if the timeout is exceeded.- See Also:
-
assertTimeout
public static <T extends @Nullable Object> T assertTimeout(Duration timeout, ThrowingSupplier<T> supplier, @Nullable String message) Assert that execution of the suppliedsuppliercompletes before the giventimeoutis exceeded.If the assertion passes then the
supplier's result is returned.Note: the
supplierwill be executed in the same thread as that of the calling code. Consequently, execution of thesupplierwill not be preemptively aborted if the timeout is exceeded.Fails with the supplied failure
message.- See Also:
-
assertTimeout
public static <T extends @Nullable Object> T assertTimeout(Duration timeout, ThrowingSupplier<T> supplier, Supplier<@Nullable String> messageSupplier) Assert that execution of the suppliedsuppliercompletes before the giventimeoutis exceeded.If the assertion passes then the
supplier's result is returned.Note: the
supplierwill be executed in the same thread as that of the calling code. Consequently, execution of thesupplierwill not be preemptively aborted if the timeout is exceeded.If necessary, the failure message will be retrieved lazily from the supplied
messageSupplier.- See Also:
-
assertTimeoutPreemptively
Assert that execution of the suppliedexecutablecompletes before the giventimeoutis exceeded.See the Preemptive Timeouts section of the class-level Javadoc for further details.
- See Also:
-
assertTimeoutPreemptively
public static void assertTimeoutPreemptively(Duration timeout, Executable executable, @Nullable String message) Assert that execution of the suppliedexecutablecompletes before the giventimeoutis exceeded.See the Preemptive Timeouts section of the class-level Javadoc for further details.
Fails with the supplied failure
message.- See Also:
-
assertTimeoutPreemptively
public static void assertTimeoutPreemptively(Duration timeout, Executable executable, Supplier<@Nullable String> messageSupplier) Assert that execution of the suppliedexecutablecompletes before the giventimeoutis exceeded.See the Preemptive Timeouts section of the class-level Javadoc for further details.
If necessary, the failure message will be retrieved lazily from the supplied
messageSupplier.- See Also:
-
assertTimeoutPreemptively
public static <T extends @Nullable Object> T assertTimeoutPreemptively(Duration timeout, ThrowingSupplier<T> supplier) Assert that execution of the suppliedsuppliercompletes before the giventimeoutis exceeded.See the Preemptive Timeouts section of the class-level Javadoc for further details.
If the assertion passes then the
supplier's result is returned.- See Also:
-
assertTimeoutPreemptively
public static <T extends @Nullable Object> T assertTimeoutPreemptively(Duration timeout, ThrowingSupplier<T> supplier, @Nullable String message) Assert that execution of the suppliedsuppliercompletes before the giventimeoutis exceeded.See the Preemptive Timeouts section of the class-level Javadoc for further details.
If the assertion passes then the
supplier's result is returned.Fails with the supplied failure
message.- See Also:
-
assertTimeoutPreemptively
public static <T extends @Nullable Object> T assertTimeoutPreemptively(Duration timeout, ThrowingSupplier<T> supplier, Supplier<@Nullable String> messageSupplier) Assert that execution of the suppliedsuppliercompletes before the giventimeoutis exceeded.See the Preemptive Timeouts section of the class-level Javadoc for further details.
If the assertion passes then the
supplier's result is returned.If necessary, the failure message will be retrieved lazily from the supplied
messageSupplier.- See Also:
-
assertInstanceOf
@API(status=STABLE, since="5.10") @Contract("_, null -> fail") public static <T> T assertInstanceOf(Class<T> expectedType, @Nullable Object actualValue) Assert that the suppliedactualValueis an instance of theexpectedType.Like the
instanceofoperator anullvalue is not considered to be of theexpectedTypeand does not pass the assertion.- Since:
- 5.8
-
assertInstanceOf
@API(status=STABLE, since="5.10") @Contract("_, null, _ -> fail") public static <T> T assertInstanceOf(Class<T> expectedType, @Nullable Object actualValue, @Nullable String message) Assert that the suppliedactualValueis an instance of theexpectedType.Like the
instanceofoperator anullvalue is not considered to be of theexpectedTypeand does not pass the assertion.Fails with the supplied failure
message.- Since:
- 5.8
-
assertInstanceOf
@Contract("_, null, _ -> fail") @API(status=STABLE, since="5.10") public static <T> T assertInstanceOf(Class<T> expectedType, @Nullable Object actualValue, Supplier<@Nullable String> messageSupplier) Assert that the suppliedactualValueis an instance of theexpectedType.Like the
instanceofoperator anullvalue is not considered to be of theexpectedTypeand does not pass the assertion.If necessary, the failure message will be retrieved lazily from the supplied
messageSupplier.- Since:
- 5.8
-