Package org.testng
Class Assert
java.lang.Object
org.testng.Assert
Assertion tool class. Presents assertion methods with a more natural parameter order. The order
is always actualValue, expectedValue [, message].
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interface
This interface facilitates the use ofexpectThrows(java.lang.Class<T>, org.testng.Assert.ThrowingRunnable)
from Java 8. -
Field Summary
Fields -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
Assert()
Protect constructor since it is a static only class -
Method Summary
Modifier and TypeMethodDescriptionprivate static boolean
areArraysEqual
(Object actual, Object expected) private static boolean
areEqual
(double actual, double expected, double delta) private static boolean
areEqual
(float actual, float expected, float delta) private static boolean
private static boolean
areEqualImpl
(Object actual, Object expected) private static void
assertArrayEquals
(Object actual, Object expected, String message) private static void
assertArrayNotEquals
(Object actual, Object expected, String message) static void
assertEquals
(boolean[] actual, boolean[] expected) Asserts that two arrays contain the same elements in the same order.static void
assertEquals
(boolean[] actual, boolean[] expected, String message) Asserts that two arrays contain the same elements in the same order.static void
assertEquals
(boolean actual, boolean expected) Asserts that two booleans are equal.static void
assertEquals
(boolean actual, boolean expected, String message) Asserts that two booleans are equal.static void
assertEquals
(byte[] actual, byte[] expected) Asserts that two arrays contain the same elements in the same order.static void
assertEquals
(byte[] actual, byte[] expected, String message) Asserts that two arrays contain the same elements in the same order.static void
assertEquals
(byte actual, byte expected) Asserts that two bytes are equal.static void
assertEquals
(byte actual, byte expected, String message) Asserts that two bytes are equal.static void
assertEquals
(char[] actual, char[] expected) Asserts that two arrays contain the same elements in the same order.static void
assertEquals
(char[] actual, char[] expected, String message) Asserts that two arrays contain the same elements in the same order.static void
assertEquals
(char actual, char expected) Asserts that two chars are equal.static void
assertEquals
(char actual, char expected, String message) Asserts that two chars are equal.static void
assertEquals
(double[] actual, double[] expected) Asserts that two arrays contain the same elements in the same order.static void
assertEquals
(double[] actual, double[] expected, double delta) Asserts that two arrays contain the equal elements concerning a delta in the same order.static void
assertEquals
(double[] actual, double[] expected, double delta, String message) Asserts that two arrays contain the equal elements concerning a delta in the same order.static void
assertEquals
(double[] actual, double[] expected, String message) Asserts that two arrays contain the same elements in the same order.static void
assertEquals
(double actual, double expected) Asserts that two doubles are equal.static void
assertEquals
(double actual, double expected, double delta) Asserts that two doubles are equal concerning a delta.static void
assertEquals
(double actual, double expected, double delta, String message) Asserts that two doubles are equal concerning a delta.static void
assertEquals
(double actual, double expected, String message) Asserts that two doubles are equal.static void
assertEquals
(float[] actual, float[] expected) Asserts that two arrays contain the same elements in the same order.static void
assertEquals
(float[] actual, float[] expected, float delta) Asserts that two arrays contain the equal elements concerning a delta in the same order.static void
assertEquals
(float[] actual, float[] expected, float delta, String message) Asserts that two arrays contain the equal elements concerning a delta in the same order.static void
assertEquals
(float[] actual, float[] expected, String message) Asserts that two arrays contain the same elements in the same order.static void
assertEquals
(float actual, float expected) Asserts that two floats are equal.static void
assertEquals
(float actual, float expected, float delta) Asserts that two floats are equal concerning a delta.static void
assertEquals
(float actual, float expected, float delta, String message) Asserts that two floats are equal concerning a delta.static void
assertEquals
(float actual, float expected, String message) Asserts that two floats are equal.static void
assertEquals
(int[] actual, int[] expected) Asserts that two arrays contain the same elements in the same order.static void
assertEquals
(int[] actual, int[] expected, String message) Asserts that two arrays contain the same elements in the same order.static void
assertEquals
(int actual, int expected) Asserts that two ints are equal.static void
assertEquals
(int actual, int expected, String message) Asserts that two ints are equal.static void
assertEquals
(long[] actual, long[] expected) Asserts that two arrays contain the same elements in the same order.static void
assertEquals
(long[] actual, long[] expected, String message) Asserts that two arrays contain the same elements in the same order.static void
assertEquals
(long actual, long expected) Asserts that two longs are equal.static void
assertEquals
(long actual, long expected, String message) Asserts that two longs are equal.static void
assertEquals
(short[] actual, short[] expected) Asserts that two arrays contain the same elements in the same order.static void
assertEquals
(short[] actual, short[] expected, String message) Asserts that two arrays contain the same elements in the same order.static void
assertEquals
(short actual, short expected) Asserts that two shorts are equal.static void
assertEquals
(short actual, short expected, String message) Asserts that two shorts are equal.static void
assertEquals
(Iterable<?> actual, Iterable<?> expected) Asserts that two iterables return iterators with the same elements in the same order.static void
assertEquals
(Iterable<?> actual, Iterable<?> expected, String message) Asserts that two iterables return iterators with the same elements in the same order.static void
assertEquals
(Object[] actual, Object[] expected) Asserts that two arrays contain the same elements in the same order.static void
assertEquals
(Object[] actual, Object[] expected, String message) Asserts that two arrays contain the same elements in the same order.static void
assertEquals
(Object actual, Object expected) Asserts that two objects are equal.static void
assertEquals
(Object actual, Object expected, String message) Asserts that two objects are equal.static void
assertEquals
(String actual, String expected) Asserts that two Strings are equal.static void
assertEquals
(String actual, String expected, String message) Asserts that two Strings are equal.static void
assertEquals
(Collection<?> actual, Collection<?> expected) Asserts that two collections contain the same elements in the same order.static void
assertEquals
(Collection<?> actual, Collection<?> expected, String message) Asserts that two collections contain the same elements in the same order.static void
assertEquals
(Iterator<?> actual, Iterator<?> expected) Asserts that two iterators return the same elements in the same order.static void
assertEquals
(Iterator<?> actual, Iterator<?> expected, String message) Asserts that two iterators return the same elements in the same order.static void
assertEquals
(Map<?, ?> actual, Map<?, ?> expected) static void
assertEquals
(Map<?, ?> actual, Map<?, ?> expected, String message) Asserts that two maps are equal.static void
assertEquals
(Set<?> actual, Set<?> expected) Asserts that two sets are equal.static void
assertEquals
(Set<?> actual, Set<?> expected, String message) Assert set equalsstatic void
assertEqualsDeep
(Map<?, ?> actual, Map<?, ?> expected) static void
assertEqualsDeep
(Map<?, ?> actual, Map<?, ?> expected, String message) static void
assertEqualsDeep
(Set<?> actual, Set<?> expected, String message) private static void
assertEqualsImpl
(Object actual, Object expected, String message) Differs fromassertEquals(Object, Object, String)
by not taking arrays into special consideration hence comparing them by reference.static void
assertEqualsNoOrder
(Object[] actual, Object[] expected) Asserts that two arrays contain the same elements in no particular order.static void
assertEqualsNoOrder
(Object[] actual, Object[] expected, String message) Asserts that two arrays contain the same elements in no particular order.static void
assertFalse
(boolean condition) Asserts that a condition is false.static void
assertFalse
(boolean condition, String message) Asserts that a condition is false.(package private) static void
assertNotEquals
(boolean actual1, boolean actual2) (package private) static void
assertNotEquals
(boolean actual1, boolean actual2, String message) (package private) static void
assertNotEquals
(byte actual1, byte actual2) (package private) static void
assertNotEquals
(byte actual1, byte actual2, String message) (package private) static void
assertNotEquals
(char actual1, char actual2) (package private) static void
assertNotEquals
(char actual1, char actual2, String message) static void
assertNotEquals
(double actual1, double actual2, double delta) static void
assertNotEquals
(double actual, double expected, double delta, String message) static void
assertNotEquals
(float actual1, float actual2, float delta) static void
assertNotEquals
(float actual, float expected, float delta, String message) (package private) static void
assertNotEquals
(int actual1, int actual2) (package private) static void
assertNotEquals
(int actual1, int actual2, String message) (package private) static void
assertNotEquals
(long actual1, long actual2) (package private) static void
assertNotEquals
(long actual1, long actual2, String message) (package private) static void
assertNotEquals
(short actual1, short actual2) (package private) static void
assertNotEquals
(short actual1, short actual2, String message) static void
assertNotEquals
(Object actual1, Object actual2) static void
assertNotEquals
(Object actual, Object expected, String message) (package private) static void
assertNotEquals
(String actual1, String actual2) (package private) static void
assertNotEquals
(String actual1, String actual2, String message) static void
assertNotEquals
(Map<?, ?> actual, Map<?, ?> expected) static void
assertNotEquals
(Map<?, ?> actual, Map<?, ?> expected, String message) static void
assertNotEquals
(Set<?> actual, Set<?> expected) static void
assertNotEquals
(Set<?> actual, Set<?> expected, String message) static void
assertNotEqualsDeep
(Map<?, ?> actual, Map<?, ?> expected) static void
assertNotEqualsDeep
(Map<?, ?> actual, Map<?, ?> expected, String message) static void
assertNotEqualsDeep
(Set<?> actual, Set<?> expected) static void
assertNotEqualsDeep
(Set<?> actual, Set<?> expected, String message) private static void
assertNotEqualsImpl
(Object actual, Object expected, String message) static void
assertNotNull
(Object object) Asserts that an object isn't null.static void
assertNotNull
(Object object, String message) Asserts that an object isn't null.static void
assertNotSame
(Object actual, Object expected) Asserts that two objects do not refer to the same object.static void
assertNotSame
(Object actual, Object expected, String message) Asserts that two objects do not refer to the same objects.static void
assertNull
(Object object) Asserts that an object is null.static void
assertNull
(Object object, String message) Asserts that an object is null.static void
assertSame
(Object actual, Object expected) Asserts that two objects refer to the same object.static void
assertSame
(Object actual, Object expected, String message) Asserts that two objects refer to the same object.static <T extends Throwable>
voidassertThrows
(Class<T> throwableClass, Assert.ThrowingRunnable runnable) Asserts thatrunnable
throws an exception of typethrowableClass
when executed.static void
assertThrows
(Assert.ThrowingRunnable runnable) Asserts thatrunnable
throws an exception when invoked.static void
assertTrue
(boolean condition) Asserts that a condition is true.static void
assertTrue
(boolean condition, String message) Asserts that a condition is true.private static boolean
checkRefEqualityAndLength
(Object actualArray, Object expectedArray, String message) This methods check referential equality of given arguments as well as references length (assuming they are arrays).static <T extends Throwable>
TexpectThrows
(Class<T> throwableClass, Assert.ThrowingRunnable runnable) Asserts thatrunnable
throws an exception of typethrowableClass
when executed and returns the exception.static void
fail()
Fails a test with no message.static void
Fails a test with the given message.static void
Fails a test with the given message and wrapping the original exception.private static void
failAssertNoEqual
(String defaultMessage, String message) private static void
failEquals
(Object actual, Object expected, String message) private static void
failNotEquals
(Object actual, Object expected, String message) private static void
failNotSame
(Object actual, Object expected, String message) private static void
(package private) static String
private static String
getArrayNotEqualReason
(Object actual, Object expected) returns not equal reason or null if equalprivate static String
getNotEqualDeepReason
(Map<?, ?> actual, Map<?, ?> expected) returns not equal deep reason or null if equalprivate static String
getNotEqualDeepReason
(Set<?> actual, Set<?> expected) returns not equal deep reason or null if equalprivate static String
getNotEqualReason
(Map<?, ?> actual, Map<?, ?> expected) private static String
getNotEqualReason
(Set<?> actual, Set<?> expected) returns not equal reason or null if equal
-
Field Details
-
ARRAY_MISMATCH_TEMPLATE
- See Also:
-
-
Constructor Details
-
Assert
protected Assert()Protect constructor since it is a static only class
-
-
Method Details
-
assertTrue
Asserts that a condition is true. If it isn't, an AssertionError, with the given message, is thrown.- Parameters:
condition
- the condition to evaluatemessage
- the assertion error message
-
assertTrue
public static void assertTrue(boolean condition) Asserts that a condition is true. If it isn't, an AssertionError is thrown.- Parameters:
condition
- the condition to evaluate
-
assertFalse
Asserts that a condition is false. If it isn't, an AssertionError, with the given message, is thrown.- Parameters:
condition
- the condition to evaluatemessage
- the assertion error message
-
assertFalse
public static void assertFalse(boolean condition) Asserts that a condition is false. If it isn't, an AssertionError is thrown.- Parameters:
condition
- the condition to evaluate
-
fail
Fails a test with the given message and wrapping the original exception.- Parameters:
message
- the assertion error messagerealCause
- the original exception
-
fail
Fails a test with the given message.- Parameters:
message
- the assertion error message
-
fail
public static void fail()Fails a test with no message. -
assertEquals
Asserts that two objects are equal. If they are not, an AssertionError, with the given message, is thrown.- Parameters:
actual
- the actual valueexpected
- the expected valuemessage
- the assertion error message
-
areEqual
-
assertEqualsImpl
Differs fromassertEquals(Object, Object, String)
by not taking arrays into special consideration hence comparing them by reference. Intended to be called directly to test equality of collections content. -
assertNotEqualsImpl
-
areEqualImpl
-
getArrayNotEqualReason
returns not equal reason or null if equal -
areArraysEqual
-
assertArrayEquals
-
assertArrayNotEquals
-
assertEquals
public static void assertEquals(byte[] actual, byte[] expected) Asserts that two arrays contain the same elements in the same order. If they do not, an AssertionError is thrown.- Parameters:
actual
- the actual valueexpected
- the expected value
-
assertEquals
Asserts that two arrays contain the same elements in the same order. If they do not, an AssertionError, with the given message, is thrown.- Parameters:
actual
- the actual valueexpected
- the expected valuemessage
- the assertion error message
-
assertEquals
public static void assertEquals(short[] actual, short[] expected) Asserts that two arrays contain the same elements in the same order. If they do not, an AssertionError is thrown.- Parameters:
actual
- the actual valueexpected
- the expected value
-
assertEquals
Asserts that two arrays contain the same elements in the same order. If they do not, an AssertionError, with the given message, is thrown.- Parameters:
actual
- the actual valueexpected
- the expected valuemessage
- the assertion error message
-
assertEquals
public static void assertEquals(int[] actual, int[] expected) Asserts that two arrays contain the same elements in the same order. If they do not, an AssertionError is thrown.- Parameters:
actual
- the actual valueexpected
- the expected value
-
assertEquals
Asserts that two arrays contain the same elements in the same order. If they do not, an AssertionError, with the given message, is thrown.- Parameters:
actual
- the actual valueexpected
- the expected valuemessage
- the assertion error message
-
assertEquals
public static void assertEquals(boolean[] actual, boolean[] expected) Asserts that two arrays contain the same elements in the same order. If they do not, an AssertionError is thrown.- Parameters:
actual
- the actual valueexpected
- the expected value
-
assertEquals
Asserts that two arrays contain the same elements in the same order. If they do not, an AssertionError, with the given message, is thrown.- Parameters:
actual
- the actual valueexpected
- the expected valuemessage
- the assertion error message
-
assertEquals
public static void assertEquals(char[] actual, char[] expected) Asserts that two arrays contain the same elements in the same order. If they do not, an AssertionError is thrown.- Parameters:
actual
- the actual valueexpected
- the expected value
-
assertEquals
Asserts that two arrays contain the same elements in the same order. If they do not, an AssertionError, with the given message, is thrown.- Parameters:
actual
- the actual valueexpected
- the expected valuemessage
- the assertion error message
-
assertEquals
public static void assertEquals(float[] actual, float[] expected) Asserts that two arrays contain the same elements in the same order. If they do not, an AssertionError is thrown.- Parameters:
actual
- the actual valueexpected
- the expected value
-
assertEquals
Asserts that two arrays contain the same elements in the same order. If they do not, an AssertionError, with the given message, is thrown.- Parameters:
actual
- the actual valueexpected
- the expected valuemessage
- the assertion error message
-
assertEquals
public static void assertEquals(float[] actual, float[] expected, float delta) Asserts that two arrays contain the equal elements concerning a delta in the same order. If they do not, an AssertionError is thrown.- Parameters:
actual
- the actual valueexpected
- the expected valuedelta
- the absolute tolerable difference between the actual and expected values
-
assertEquals
Asserts that two arrays contain the equal elements concerning a delta in the same order. If they do not, an AssertionError is thrown.- Parameters:
actual
- the actual valueexpected
- the expected valuedelta
- the absolute tolerable difference between the actual and expected valuesmessage
- the assertion error message
-
assertEquals
public static void assertEquals(double[] actual, double[] expected) Asserts that two arrays contain the same elements in the same order. If they do not, an AssertionError is thrown.- Parameters:
actual
- the actual valueexpected
- the expected value
-
assertEquals
Asserts that two arrays contain the same elements in the same order. If they do not, an AssertionError, with the given message, is thrown.- Parameters:
actual
- the actual valueexpected
- the expected valuemessage
- the assertion error message
-
assertEquals
public static void assertEquals(double[] actual, double[] expected, double delta) Asserts that two arrays contain the equal elements concerning a delta in the same order. If they do not, an AssertionError is thrown.- Parameters:
actual
- the actual valueexpected
- the expected valuedelta
- the absolute tolerable difference between the actual and expected values
-
assertEquals
Asserts that two arrays contain the equal elements concerning a delta in the same order. If they do not, an AssertionError, with the given message, is thrown.- Parameters:
actual
- the actual valueexpected
- the expected valuedelta
- the absolute tolerable difference between the actual and expected valuesmessage
- the assertion error message
-
assertEquals
public static void assertEquals(long[] actual, long[] expected) Asserts that two arrays contain the same elements in the same order. If they do not, an AssertionError is thrown.- Parameters:
actual
- the actual valueexpected
- the expected value
-
assertEquals
Asserts that two arrays contain the same elements in the same order. If they do not, an AssertionError, with the given message, is thrown.- Parameters:
actual
- the actual valueexpected
- the expected valuemessage
- the assertion error message
-
checkRefEqualityAndLength
private static boolean checkRefEqualityAndLength(Object actualArray, Object expectedArray, String message) This methods check referential equality of given arguments as well as references length (assuming they are arrays). Successful execution of this method guaranties arrays length equality.- Parameters:
actualArray
- array of elementsexpectedArray
- array of elementsmessage
- the assertion error message- Returns:
true
ifactualArray
andexpectedArray
are the same,false
otherwise. If references are different and arrays length are differentAssertionError
is thrown.
-
assertEquals
Asserts that two objects are equal. If they are not, an AssertionError is thrown.- Parameters:
actual
- the actual valueexpected
- the expected value
-
assertEquals
Asserts that two Strings are equal. If they are not, an AssertionError, with the given message, is thrown.- Parameters:
actual
- the actual valueexpected
- the expected valuemessage
- the assertion error message
-
assertEquals
Asserts that two Strings are equal. If they are not, an AssertionError is thrown.- Parameters:
actual
- the actual valueexpected
- the expected value
-
areEqual
private static boolean areEqual(double actual, double expected, double delta) -
assertEquals
Asserts that two doubles are equal concerning a delta. If they are not, an AssertionError, with the given message, is thrown. If the expected value is infinity then the delta value is ignored.- Parameters:
actual
- the actual valueexpected
- the expected valuedelta
- the absolute tolerable difference between the actual and expected valuesmessage
- the assertion error message
-
assertEquals
public static void assertEquals(double actual, double expected, double delta) Asserts that two doubles are equal concerning a delta. If they are not, an AssertionError is thrown. If the expected value is infinity then the delta value is ignored.- Parameters:
actual
- the actual valueexpected
- the expected valuedelta
- the absolute tolerable difference between the actual and expected values
-
assertEquals
Asserts that two doubles are equal. If they are not, an AssertionError, with the given message, is thrown.- Parameters:
actual
- the actual valueexpected
- the expected valuemessage
- the assertion error message
-
assertEquals
public static void assertEquals(double actual, double expected) Asserts that two doubles are equal. If they are not, an AssertionError is thrown.- Parameters:
actual
- the actual valueexpected
- the expected value
-
areEqual
private static boolean areEqual(float actual, float expected, float delta) -
assertEquals
Asserts that two floats are equal concerning a delta. If they are not, an AssertionError, with the given message, is thrown. If the expected value is infinity then the delta value is ignored.- Parameters:
actual
- the actual valueexpected
- the expected valuedelta
- the absolute tolerable difference between the actual and expected valuesmessage
- the assertion error message
-
assertEquals
public static void assertEquals(float actual, float expected, float delta) Asserts that two floats are equal concerning a delta. If they are not, an AssertionError is thrown. If the expected value is infinity then the delta value is ignored.- Parameters:
actual
- the actual valueexpected
- the expected valuedelta
- the absolute tolerable difference between the actual and expected values
-
assertEquals
Asserts that two floats are equal. If they are not, an AssertionError, with the given message, is thrown.- Parameters:
actual
- the actual valueexpected
- the expected valuemessage
- the assertion error message
-
assertEquals
public static void assertEquals(float actual, float expected) Asserts that two floats are equal. If they are not, an AssertionError is thrown.- Parameters:
actual
- the actual valueexpected
- the expected value
-
assertEquals
Asserts that two longs are equal. If they are not, an AssertionError, with the given message, is thrown.- Parameters:
actual
- the actual valueexpected
- the expected valuemessage
- the assertion error message
-
assertEquals
public static void assertEquals(long actual, long expected) Asserts that two longs are equal. If they are not, an AssertionError is thrown.- Parameters:
actual
- the actual valueexpected
- the expected value
-
assertEquals
Asserts that two booleans are equal. If they are not, an AssertionError, with the given message, is thrown.- Parameters:
actual
- the actual valueexpected
- the expected valuemessage
- the assertion error message
-
assertEquals
public static void assertEquals(boolean actual, boolean expected) Asserts that two booleans are equal. If they are not, an AssertionError is thrown.- Parameters:
actual
- the actual valueexpected
- the expected value
-
assertEquals
Asserts that two bytes are equal. If they are not, an AssertionError, with the given message, is thrown.- Parameters:
actual
- the actual valueexpected
- the expected valuemessage
- the assertion error message
-
assertEquals
public static void assertEquals(byte actual, byte expected) Asserts that two bytes are equal. If they are not, an AssertionError is thrown.- Parameters:
actual
- the actual valueexpected
- the expected value
-
assertEquals
Asserts that two chars are equal. If they are not, an AssertionFailedError, with the given message, is thrown.- Parameters:
actual
- the actual valueexpected
- the expected valuemessage
- the assertion error message
-
assertEquals
public static void assertEquals(char actual, char expected) Asserts that two chars are equal. If they are not, an AssertionError is thrown.- Parameters:
actual
- the actual valueexpected
- the expected value
-
assertEquals
Asserts that two shorts are equal. If they are not, an AssertionFailedError, with the given message, is thrown.- Parameters:
actual
- the actual valueexpected
- the expected valuemessage
- the assertion error message
-
assertEquals
public static void assertEquals(short actual, short expected) Asserts that two shorts are equal. If they are not, an AssertionError is thrown.- Parameters:
actual
- the actual valueexpected
- the expected value
-
assertEquals
Asserts that two ints are equal. If they are not, an AssertionFailedError, with the given message, is thrown.- Parameters:
actual
- the actual valueexpected
- the expected valuemessage
- the assertion error message
-
assertEquals
public static void assertEquals(int actual, int expected) Asserts that two ints are equal. If they are not, an AssertionError is thrown.- Parameters:
actual
- the actual valueexpected
- the expected value
-
assertNotNull
Asserts that an object isn't null. If it is, an AssertionError is thrown.- Parameters:
object
- the assertion object
-
assertNotNull
Asserts that an object isn't null. If it is, an AssertionFailedError, with the given message, is thrown.- Parameters:
object
- the assertion objectmessage
- the assertion error message
-
assertNull
Asserts that an object is null. If it is not, an AssertionError, with the given message, is thrown.- Parameters:
object
- the assertion object
-
assertNull
Asserts that an object is null. If it is not, an AssertionFailedError, with the given message, is thrown.- Parameters:
object
- the assertion objectmessage
- the assertion error message
-
assertSame
Asserts that two objects refer to the same object. If they do not, an AssertionFailedError, with the given message, is thrown.- Parameters:
actual
- the actual valueexpected
- the expected valuemessage
- the assertion error message
-
assertSame
Asserts that two objects refer to the same object. If they do not, an AssertionError is thrown.- Parameters:
actual
- the actual valueexpected
- the expected value
-
assertNotSame
Asserts that two objects do not refer to the same objects. If they do, an AssertionError, with the given message, is thrown.- Parameters:
actual
- the actual valueexpected
- the expected valuemessage
- the assertion error message
-
assertNotSame
Asserts that two objects do not refer to the same object. If they do, an AssertionError is thrown.- Parameters:
actual
- the actual valueexpected
- the expected value
-
failSame
-
failNotSame
-
failNotEquals
-
failEquals
-
format
-
assertEquals
Asserts that two collections contain the same elements in the same order. If they do not, an AssertionError is thrown.- Parameters:
actual
- the actual valueexpected
- the expected value
-
assertEquals
Asserts that two collections contain the same elements in the same order. If they do not, an AssertionError, with the given message, is thrown.- Parameters:
actual
- the actual valueexpected
- the expected valuemessage
- the assertion error message
-
assertEquals
Asserts that two iterators return the same elements in the same order. If they do not, an AssertionError is thrown. Please note that this assert iterates over the elements and modifies the state of the iterators.- Parameters:
actual
- the actual valueexpected
- the expected value
-
assertEquals
Asserts that two iterators return the same elements in the same order. If they do not, an AssertionError, with the given message, is thrown. Please note that this assert iterates over the elements and modifies the state of the iterators.- Parameters:
actual
- the actual valueexpected
- the expected valuemessage
- the assertion error message
-
assertEquals
Asserts that two iterables return iterators with the same elements in the same order. If they do not, an AssertionError is thrown.- Parameters:
actual
- the actual valueexpected
- the expected value
-
assertEquals
Asserts that two iterables return iterators with the same elements in the same order. If they do not, an AssertionError, with the given message, is thrown.- Parameters:
actual
- the actual valueexpected
- the expected valuemessage
- the assertion error message
-
assertEquals
Asserts that two arrays contain the same elements in the same order. If they do not, an AssertionError, with the given message, is thrown.- Parameters:
actual
- the actual valueexpected
- the expected valuemessage
- the assertion error message
-
assertEqualsNoOrder
Asserts that two arrays contain the same elements in no particular order. If they do not, an AssertionError, with the given message, is thrown.- Parameters:
actual
- the actual valueexpected
- the expected valuemessage
- the assertion error message
-
failAssertNoEqual
-
assertEquals
Asserts that two arrays contain the same elements in the same order. If they do not, an AssertionError is thrown.- Parameters:
actual
- the actual valueexpected
- the expected value
-
assertEqualsNoOrder
Asserts that two arrays contain the same elements in no particular order. If they do not, an AssertionError is thrown.- Parameters:
actual
- the actual valueexpected
- the expected value
-
assertEquals
Asserts that two sets are equal.- Parameters:
actual
- The actual valueexpected
- The expected value
-
getNotEqualReason
returns not equal reason or null if equal -
assertEquals
Assert set equals- Parameters:
actual
- The actual valueexpected
- The expected valuemessage
- The message
-
getNotEqualDeepReason
returns not equal deep reason or null if equal -
assertEqualsDeep
-
assertEquals
-
getNotEqualReason
-
assertEquals
Asserts that two maps are equal.- Parameters:
actual
- The actual valueexpected
- The expected valuemessage
- The message
-
assertEqualsDeep
-
getNotEqualDeepReason
returns not equal deep reason or null if equal -
assertEqualsDeep
-
assertNotEquals
-
assertNotEquals
-
assertNotEquals
-
assertNotEquals
-
assertNotEquals
-
assertNotEquals
static void assertNotEquals(long actual1, long actual2) -
assertNotEquals
-
assertNotEquals
static void assertNotEquals(boolean actual1, boolean actual2) -
assertNotEquals
-
assertNotEquals
static void assertNotEquals(byte actual1, byte actual2) -
assertNotEquals
-
assertNotEquals
static void assertNotEquals(char actual1, char actual2) -
assertNotEquals
-
assertNotEquals
static void assertNotEquals(short actual1, short actual2) -
assertNotEquals
-
assertNotEquals
static void assertNotEquals(int actual1, int actual2) -
assertNotEquals
-
assertNotEquals
public static void assertNotEquals(float actual1, float actual2, float delta) -
assertNotEquals
-
assertNotEquals
-
assertNotEquals
-
assertNotEqualsDeep
-
assertNotEqualsDeep
-
assertNotEquals
-
assertNotEquals
-
assertNotEqualsDeep
-
assertNotEqualsDeep
-
assertNotEquals
public static void assertNotEquals(double actual1, double actual2, double delta) -
assertThrows
Asserts thatrunnable
throws an exception when invoked. If it does not, anAssertionError
is thrown.- Parameters:
runnable
- A function that is expected to throw an exception when invoked- Since:
- 6.9.5
-
assertThrows
public static <T extends Throwable> void assertThrows(Class<T> throwableClass, Assert.ThrowingRunnable runnable) Asserts thatrunnable
throws an exception of typethrowableClass
when executed. If it does not throw an exception, anAssertionError
is thrown. If it throws the wrong type of exception, anAssertionError
is thrown describing the mismatch; the exception that was actually thrown can be obtained by callingThrowable.getCause()
.- Type Parameters:
T
- the expected type of the exception- Parameters:
throwableClass
- the expected type of the exceptionrunnable
- A function that is expected to throw an exception when invoked- Since:
- 6.9.5
-
expectThrows
public static <T extends Throwable> T expectThrows(Class<T> throwableClass, Assert.ThrowingRunnable runnable) Asserts thatrunnable
throws an exception of typethrowableClass
when executed and returns the exception. Ifrunnable
does not throw an exception, anAssertionError
is thrown. If it throws the wrong type of exception, anAssertionError
is thrown describing the mismatch; the exception that was actually thrown can be obtained by callingThrowable.getCause()
.- Type Parameters:
T
- the expected type of the exception- Parameters:
throwableClass
- the expected type of the exceptionrunnable
- A function that is expected to throw an exception when invoked- Returns:
- The exception thrown by
runnable
- Since:
- 6.9.5
-