Top Description Inners Fields Constructors Methods
org.testng

public Class Assert

extends Object
Class Inheritance
Static Imports
org.testng.internal.EclipseInterface.ASSERT_EQUAL_LEFT, .EclipseInterface.ASSERT_LEFT2, .EclipseInterface.ASSERT_MIDDLE, .EclipseInterface.ASSERT_RIGHT, .EclipseInterface.ASSERT_UNEQUAL_LEFT

Assertion tool class. Presents assertion methods with a more natural parameter order. The order is always actualValue, expectedValue [, message].

Important Note

Assertion methods comparing two values for equality, such as assertEquals, are only intended to test equality for an actual and an (un-)expected result value. They are not designed for testing whether a class correctly implements equals(Object). For example assertEquals might return fast when provided with the same object as actual and expected value without calling equals(Object) at all. Such tests trying to verify the equals(Object) implementation should instead be written explicitly and assertTrue or assertFalse should be used to verify the result, e.g.: assertTrue(var.equals(var)), assertFalse(var.equals(null)).

Author
Alexandru Popescu

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static interface
Assert.ThrowingRunnable

This interface facilitates the use of expectThrows from Java 8.

Field Summary

Modifier and TypeField and Description
public static final String

Constructor Summary

AccessConstructor and Description
protected
Assert()

Protect constructor since it is a static only class

Method Summary

Modifier and TypeMethod and Description
private static boolean
areArraysEqual(Object actual, Object expected)

private static boolean
areEqual(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
areEqualImpl(Object actual, Object expected)

private static boolean
areNotEqualImpl(Object actual, Object expected)

private static void
assertArrayEquals(Object actual, Object expected, String message)

private static void
assertArrayNotEquals(Object actual, Object expected, String message)

public static void
assertEquals(Object
the actual value
actual
,
Object
the expected value
expected
,
String
the assertion error message
message
)

Asserts that two objects are equal.

public static void
assertEquals(byte[]
the actual value
actual
,
byte[]
the expected value
expected
)

Asserts that two arrays contain the same elements in the same order.

public static void
assertEquals(byte[]
the actual value
actual
,
byte[]
the expected value
expected
,
String
the assertion error message
message
)

Asserts that two arrays contain the same elements in the same order.

public static void
assertEquals(short[]
the actual value
actual
,
short[]
the expected value
expected
)

Asserts that two arrays contain the same elements in the same order.

public static void
assertEquals(short[]
the actual value
actual
,
short[]
the expected value
expected
,
String
the assertion error message
message
)

Asserts that two arrays contain the same elements in the same order.

public static void
assertEquals(int[]
the actual value
actual
,
int[]
the expected value
expected
)

Asserts that two arrays contain the same elements in the same order.

public static void
assertEquals(int[]
the actual value
actual
,
int[]
the expected value
expected
,
String
the assertion error message
message
)

Asserts that two arrays contain the same elements in the same order.

public static void
assertEquals(boolean[]
the actual value
actual
,
boolean[]
the expected value
expected
)

Asserts that two arrays contain the same elements in the same order.

public static void
assertEquals(boolean[]
the actual value
actual
,
boolean[]
the expected value
expected
,
String
the assertion error message
message
)

Asserts that two arrays contain the same elements in the same order.

public static void
assertEquals(char[]
the actual value
actual
,
char[]
the expected value
expected
)

Asserts that two arrays contain the same elements in the same order.

public static void
assertEquals(char[]
the actual value
actual
,
char[]
the expected value
expected
,
String
the assertion error message
message
)

Asserts that two arrays contain the same elements in the same order.

public static void
assertEquals(float[]
the actual value
actual
,
float[]
the expected value
expected
)

Asserts that two arrays contain the same elements in the same order.

public static void
assertEquals(float[]
the actual value
actual
,
float[]
the expected value
expected
,
String
the assertion error message
message
)

Asserts that two arrays contain the same elements in the same order.

public static void
assertEquals(float[]
the actual value
actual
,
float[]
the expected value
expected
,
float
the absolute tolerable difference between the actual and expected values
delta
)

Asserts that two arrays contain the equal elements concerning a delta in the same order.

public static void
assertEquals(float[]
the actual value
actual
,
float[]
the expected value
expected
,
float
the absolute tolerable difference between the actual and expected values
delta
,
String
the assertion error message
message
)

Asserts that two arrays contain the equal elements concerning a delta in the same order.

public static void
assertEquals(double[]
the actual value
actual
,
double[]
the expected value
expected
)

Asserts that two arrays contain the same elements in the same order.

public static void
assertEquals(double[]
the actual value
actual
,
double[]
the expected value
expected
,
String
the assertion error message
message
)

Asserts that two arrays contain the same elements in the same order.

public static void
assertEquals(double[]
the actual value
actual
,
double[]
the expected value
expected
,
double
the absolute tolerable difference between the actual and expected values
delta
)

Asserts that two arrays contain the equal elements concerning a delta in the same order.

public static void
assertEquals(double[]
the actual value
actual
,
double[]
the expected value
expected
,
double
the absolute tolerable difference between the actual and expected values
delta
,
String
the assertion error message
message
)

Asserts that two arrays contain the equal elements concerning a delta in the same order.

public static void
assertEquals(long[]
the actual value
actual
,
long[]
the expected value
expected
)

Asserts that two arrays contain the same elements in the same order.

public static void
assertEquals(long[]
the actual value
actual
,
long[]
the expected value
expected
,
String
the assertion error message
message
)

Asserts that two arrays contain the same elements in the same order.

public static void
assertEquals(Object
the actual value
actual
,
Object
the expected value
expected
)

Asserts that two objects are equal.

public static void
assertEquals(String
the actual value
actual
,
String
the expected value
expected
,
String
the assertion error message
message
)

Asserts that two Strings are equal.

public static void
assertEquals(String
the actual value
actual
,
String
the expected value
expected
)

Asserts that two Strings are equal.

public static void
assertEquals(double
the actual value
actual
,
double
the expected value
expected
,
double
the absolute tolerable difference between the actual and expected values
delta
,
String
the assertion error message
message
)

Asserts that two doubles are equal concerning a delta.

public static void
assertEquals(double
the actual value
actual
,
double
the expected value
expected
,
double
the absolute tolerable difference between the actual and expected values
delta
)

Asserts that two doubles are equal concerning a delta.

public static void
assertEquals(double
the actual value
actual
,
double
the expected value
expected
,
String
the assertion error message
message
)

Asserts that two doubles are equal.

public static void
assertEquals(Double
the actual value
actual
,
double
the expected value
expected
,
String
the assertion error message
message
)

Asserts that two doubles are equal.

public static void
assertEquals(double
the actual value
actual
,
Double
the expected value
expected
,
String
the assertion error message
message
)

Asserts that two doubles are equal.

public static void
assertEquals(Double
the actual value
actual
,
Double
the expected value
expected
,
String
the assertion error message
message
)

Asserts that two doubles are equal.

public static void
assertEquals(double
the actual value
actual
,
double
the expected value
expected
)

Asserts that two doubles are equal.

public static void
assertEquals(Double
the actual value
actual
,
double
the expected value
expected
)

Asserts that two doubles are equal.

public static void
assertEquals(double
the actual value
actual
,
Double
the expected value
expected
)

Asserts that two doubles are equal.

public static void
assertEquals(Double
the actual value
actual
,
Double
the expected value
expected
)

Asserts that two doubles are equal.

public static void
assertEquals(float
the actual value
actual
,
float
the expected value
expected
,
float
the absolute tolerable difference between the actual and expected values
delta
,
String
the assertion error message
message
)

Asserts that two floats are equal concerning a delta.

public static void
assertEquals(float
the actual value
actual
,
float
the expected value
expected
,
float
the absolute tolerable difference between the actual and expected values
delta
)

Asserts that two floats are equal concerning a delta.

public static void
assertEquals(float
the actual value
actual
,
float
the expected value
expected
,
String
the assertion error message
message
)

Asserts that two floats are equal.

public static void
assertEquals(Float
the actual value
actual
,
float
the expected value
expected
,
String
the assertion error message
message
)

Asserts that two floats are equal.

public static void
assertEquals(float
the actual value
actual
,
Float
the expected value
expected
,
String
the assertion error message
message
)

Asserts that two floats are equal.

public static void
assertEquals(Float
the actual value
actual
,
Float
the expected value
expected
,
String
the assertion error message
message
)

Asserts that two floats are equal.

public static void
assertEquals(float
the actual value
actual
,
float
the expected value
expected
)

Asserts that two floats are equal.

public static void
assertEquals(Float
the actual value
actual
,
float
the expected value
expected
)

Asserts that two floats are equal.

public static void
assertEquals(float
the actual value
actual
,
Float
the expected value
expected
)

Asserts that two floats are equal.

public static void
assertEquals(Float
the actual value
actual
,
Float
the expected value
expected
)

Asserts that two floats are equal.

public static void
assertEquals(long
the actual value
actual
,
long
the expected value
expected
,
String
the assertion error message
message
)

Asserts that two longs are equal.

public static void
assertEquals(Long
the actual value
actual
,
long
the expected value
expected
,
String
the assertion error message
message
)

Asserts that two longs are equal.

public static void
assertEquals(Long
the actual value
actual
,
Long
the expected value
expected
,
String
the assertion error message
message
)

Asserts that two longs are equal.

public static void
assertEquals(long
the actual value
actual
,
long
the expected value
expected
)

Asserts that two longs are equal.

public static void
assertEquals(Long
the actual value
actual
,
long
the expected value
expected
)

Asserts that two longs are equal.

public static void
assertEquals(long
the actual value
actual
,
Long
the expected value
expected
)

Asserts that two longs are equal.

public static void
assertEquals(Long
the actual value
actual
,
Long
the expected value
expected
)

Asserts that two longs are equal.

public static void
assertEquals(boolean
the actual value
actual
,
boolean
the expected value
expected
,
String
the assertion error message
message
)

Asserts that two booleans are equal.

public static void
assertEquals(Boolean
the actual value
actual
,
boolean
the expected value
expected
,
String
the assertion error message
message
)

Asserts that two booleans are equal.

public static void
assertEquals(boolean
the actual value
actual
,
Boolean
the expected value
expected
,
String
the assertion error message
message
)

Asserts that two booleans are equal.

public static void
assertEquals(Boolean
the actual value
actual
,
Boolean
the expected value
expected
,
String
the assertion error message
message
)

Asserts that two booleans are equal.

public static void
assertEquals(boolean
the actual value
actual
,
boolean
the expected value
expected
)

Asserts that two booleans are equal.

public static void
assertEquals(Boolean
the actual value
actual
,
boolean
the expected value
expected
)

Asserts that two booleans are equal.

public static void
assertEquals(Boolean
the actual value
actual
,
Boolean
the expected value
expected
)

Asserts that two booleans are equal.

public static void
assertEquals(boolean
the actual value
actual
,
Boolean
the expected value
expected
)

Asserts that two booleans are equal.

public static void
assertEquals(byte
the actual value
actual
,
byte
the expected value
expected
,
String
the assertion error message
message
)

Asserts that two bytes are equal.

public static void
assertEquals(Byte
the actual value
actual
,
byte
the expected value
expected
,
String
the assertion error message
message
)

Asserts that two bytes are equal.

public static void
assertEquals(byte
the actual value
actual
,
Byte
the expected value
expected
,
String
the assertion error message
message
)

Asserts that two bytes are equal.

public static void
assertEquals(Byte
the actual value
actual
,
Byte
the expected value
expected
,
String
the assertion error message
message
)

Asserts that two bytes are equal.

public static void
assertEquals(byte
the actual value
actual
,
byte
the expected value
expected
)

Asserts that two bytes are equal.

public static void
assertEquals(Byte
the actual value
actual
,
byte
the expected value
expected
)

Asserts that two bytes are equal.

public static void
assertEquals(Byte
the actual value
actual
,
Byte
the expected value
expected
)

Asserts that two bytes are equal.

public static void
assertEquals(byte
the actual value
actual
,
Byte
the expected value
expected
)

Asserts that two bytes are equal.

public static void
assertEquals(char
the actual value
actual
,
char
the expected value
expected
,
String
the assertion error message
message
)

Asserts that two chars are equal.

public static void
assertEquals(Character
the actual value
actual
,
char
the expected value
expected
,
String
the assertion error message
message
)

Asserts that two chars are equal.

public static void
assertEquals(char
the actual value
actual
,
Character
the expected value
expected
,
String
the assertion error message
message
)

Asserts that two chars are equal.

public static void
assertEquals(Character
the actual value
actual
,
Character
the expected value
expected
,
String
the assertion error message
message
)

Asserts that two chars are equal.

public static void
assertEquals(char
the actual value
actual
,
char
the expected value
expected
)

Asserts that two chars are equal.

public static void
assertEquals(Character
the actual value
actual
,
char
the expected value
expected
)

Asserts that two chars are equal.

public static void
assertEquals(char
the actual value
actual
,
Character
the expected value
expected
)

Asserts that two chars are equal.

public static void
assertEquals(Character
the actual value
actual
,
Character
the expected value
expected
)

Asserts that two chars are equal.

public static void
assertEquals(short
the actual value
actual
,
short
the expected value
expected
,
String
the assertion error message
message
)

Asserts that two shorts are equal.

public static void
assertEquals(Short
the actual value
actual
,
short
the expected value
expected
,
String
the assertion error message
message
)

Asserts that two shorts are equal.

public static void
assertEquals(short
the actual value
actual
,
Short
the expected value
expected
,
String
the assertion error message
message
)

Asserts that two shorts are equal.

public static void
assertEquals(Short
the actual value
actual
,
Short
the expected value
expected
,
String
the assertion error message
message
)

Asserts that two shorts are equal.

public static void
assertEquals(short
the actual value
actual
,
short
the expected value
expected
)

Asserts that two shorts are equal.

public static void
assertEquals(Short
the actual value
actual
,
short
the expected value
expected
)

Asserts that two shorts are equal.

public static void
assertEquals(short
the actual value
actual
,
Short
the expected value
expected
)

Asserts that two shorts are equal.

public static void
assertEquals(Short
the actual value
actual
,
Short
the expected value
expected
)

Asserts that two shorts are equal.

public static void
assertEquals(int
the actual value
actual
,
int
the expected value
expected
,
String
the assertion error message
message
)

Asserts that two ints are equal.

public static void
assertEquals(Integer
the actual value
actual
,
int
the expected value
expected
,
String
the assertion error message
message
)

Asserts that two ints are equal.

public static void
assertEquals(int
the actual value
actual
,
Integer
the expected value
expected
,
String
the assertion error message
message
)

Asserts that two ints are equal.

public static void
assertEquals(Integer
the actual value
actual
,
Integer
the expected value
expected
,
String
the assertion error message
message
)

Asserts that two ints are equal.

public static void
assertEquals(int
the actual value
actual
,
int
the expected value
expected
)

Asserts that two ints are equal.

public static void
assertEquals(Integer
the actual value
actual
,
int
the expected value
expected
)

Asserts that two ints are equal.

public static void
assertEquals(int
the actual value
actual
,
Integer
the expected value
expected
)

Asserts that two ints are equal.

public static void
assertEquals(Integer
the actual value
actual
,
Integer
the expected value
expected
)

Asserts that two ints are equal.

public static void
assertEquals(Collection<?>
the actual value
actual
,
Collection<?>
the expected value
expected
)

Asserts that two collections contain the same elements in the same order.

public static void
assertEquals(Collection<?>
the actual value
actual
,
Collection<?>
the expected value
expected
,
String
the assertion error message
message
)

Asserts that two collections contain the same elements in the same order.

public static void
assertEquals(Iterator<?>
the actual value
actual
,
Iterator<?>
the expected value
expected
)

Asserts that two iterators return the same elements in the same order.

public static void
assertEquals(Iterator<?>
the actual value
actual
,
Iterator<?>
the expected value
expected
,
String
the assertion error message
message
)

Asserts that two iterators return the same elements in the same order.

public static void
assertEquals(Iterable<?>
the actual value
actual
,
Iterable<?>
the expected value
expected
)

Asserts that two iterables return iterators with the same elements in the same order.

public static void
assertEquals(Iterable<?>
the actual value
actual
,
Iterable<?>
the expected value
expected
,
String
the assertion error message
message
)

Asserts that two iterables return iterators with the same elements in the same order.

public static void
assertEquals(Object[]
the actual value
actual
,
Object[]
the expected value
expected
,
String
the assertion error message
message
)

Asserts that two arrays contain the same elements in the same order.

public static void
assertEquals(Object[]
the actual value
actual
,
Object[]
the expected value
expected
)

Asserts that two arrays contain the same elements in the same order.

public static void
assertEquals(Set<?>
The actual value
actual
,
Set<?>
The expected value
expected
)

Asserts that two sets are equal.

public static void
assertEquals(Set<?>
The actual value
actual
,
Set<?>
The expected value
expected
,
String
The message
message
)

Assert set equals

public static void
assertEquals(Map<?, ?> actual, Map<?, ?> expected)

public static void
assertEquals(Map<?, ?>
The actual value
actual
,
Map<?, ?>
The expected value
expected
,
String
The message
message
)

Asserts that two maps are equal.

public static void
assertEqualsDeep(Set<?> actual, Set<?> expected, String message)

public static void
assertEqualsDeep(Map<?, ?> actual, Map<?, ?> expected)

public static void
assertEqualsDeep(Map<?, ?> actual, Map<?, ?> expected, String message)

private static void
assertEqualsImpl(Object actual, Object expected, String message)

Differs from assertEquals(Object, Object, String) by not taking arrays into special consideration hence comparing them by reference.

public static void
assertEqualsNoOrder(Object[]
the actual value
actual
,
Object[]
the expected value
expected
,
String
the assertion error message
message
)

Asserts that two arrays contain the same elements in no particular order.

public static void
assertEqualsNoOrder(Collection<?>
the actual value
actual
,
Collection<?>
the expected value
expected
,
String
the assertion error message
message
)

Asserts that two collection contain the same elements in no particular order.

public static void
assertEqualsNoOrder(Iterator<?>
the actual value
actual
,
Iterator<?>
the expected value
expected
,
String
the assertion error message
message
)

Asserts that two iterators contain the same elements in no particular order.

public static void
assertEqualsNoOrder(Object[]
the actual value
actual
,
Object[]
the expected value
expected
)

Asserts that two arrays contain the same elements in no particular order.

public static void
assertEqualsNoOrder(Collection<?>
the actual value
actual
,
Collection<?>
the expected value
expected
)

Asserts that two collection contain the same elements in no particular order.

public static void
assertEqualsNoOrder(Iterator<?>
the actual value
actual
,
Iterator<?>
the expected value
expected
)

Asserts that two iterators contain the same elements in no particular order.

public static void
assertFalse(boolean
the condition to evaluate
condition
,
String
the assertion error message
message
)

Asserts that a condition is false.

public static void
assertFalse(boolean
the condition to evaluate
condition
)

Asserts that a condition is false.

public static <
type of object
T
>
void
assertListContains(List<T>
the list to search in
list
,
Predicate<T>
the Predicate to match object
predicate
,
String
the fail message
message
)

Asserts that List contains object by specific Predicate.

public static <
type of object
T
>
void
assertListContainsObject(List<T>
the list to search in
list
,
T
the object to search in list
object
,
String
the fail message
message
)

Asserts that List contains object.

public static <
type of object
T
>
void
assertListNotContains(List<T>
the list to search in
list
,
Predicate<T>
the Predicate to match object
predicate
,
String
the fail message
message
)

Asserts that List not contains object by specific Predicate.

public static <
type of object
T
>
void
assertListNotContainsObject(List<T>
the list to search in
list
,
T
to search in list
object
,
String
the fail message
message
)

Asserts that List not contains object.

public static void
assertNotEquals(Object actual, Object expected, String message)

public static void
assertNotEquals(Object[] actual, Object[] expected, String message)

public static void
assertNotEquals(Iterator<?> actual, Iterator<?> expected, String message)

public static void
assertNotEquals(Collection<?> actual, Collection<?> expected, String message)

public static void
assertNotEquals(Object actual, Object expected)

public static void
assertNotEquals(Collection<?> actual, Collection<?> expected)

public static void
assertNotEquals(Iterator<?> actual, Iterator<?> expected)

pack-priv static void
assertNotEquals(String actual, String expected, String message)

pack-priv static void
assertNotEquals(String actual, String expectec)

pack-priv static void
assertNotEquals(long actual, long expected, String message)

pack-priv static void
assertNotEquals(long actual, long expected)

pack-priv static void
assertNotEquals(boolean actual, boolean expected, String message)

pack-priv static void
assertNotEquals(boolean actual, boolean expected)

pack-priv static void
assertNotEquals(byte actual, byte expected, String message)

pack-priv static void
assertNotEquals(byte actual, byte expected)

pack-priv static void
assertNotEquals(char actual, char expected, String message)

pack-priv static void
assertNotEquals(char actual, char expected)

pack-priv static void
assertNotEquals(short actual, short expected, String message)

pack-priv static void
assertNotEquals(short actual, short expected)

pack-priv static void
assertNotEquals(int actual, int expected, String message)

pack-priv static void
assertNotEquals(int actual, int expected)

public static void
assertNotEquals(float actual, float expected, float delta, String message)

public static void
assertNotEquals(float actual, float expected, float delta)

public static void
assertNotEquals(double actual, double expected, double delta, String message)

public static void
assertNotEquals(Set<?> actual, Set<?> expected)

public static void
assertNotEquals(Set<?> actual, Set<?> expected, String message)

public static void
assertNotEquals(Map<?, ?> actual, Map<?, ?> expected)

public static void
assertNotEquals(Map<?, ?> actual, Map<?, ?> expected, String message)

public static void
assertNotEquals(double actual, double expected, double delta)

public static void
assertNotEqualsDeep(Set<?> actual, Set<?> expected)

public static void
assertNotEqualsDeep(Set<?> actual, Set<?> expected, String message)

public static void
assertNotEqualsDeep(Map<?, ?> actual, Map<?, ?> expected)

public static void
assertNotEqualsDeep(Map<?, ?> actual, Map<?, ?> expected, String message)

private static void
assertNotEqualsImpl(Object actual, Object expected, String message)

public static void
assertNotNull(Object
the assertion object
object
)

Asserts that an object isn't null.

public static void
assertNotNull(Object
the assertion object
object
,
String
the assertion error message
message
)

Asserts that an object isn't null.

public static void
assertNotSame(Object
the actual value
actual
,
Object
the expected value
expected
,
String
the assertion error message
message
)

Asserts that two objects do not refer to the same objects.

public static void
assertNotSame(Object
the actual value
actual
,
Object
the expected value
expected
)

Asserts that two objects do not refer to the same object.

public static void
assertNull(Object
the assertion object
object
)

Asserts that an object is null.

public static void
assertNull(Object
the assertion object
object
,
String
the assertion error message
message
)

Asserts that an object is null.

public static void
assertSame(Object
the actual value
actual
,
Object
the expected value
expected
,
String
the assertion error message
message
)

Asserts that two objects refer to the same object.

public static void
assertSame(Object
the actual value
actual
,
Object
the expected value
expected
)

Asserts that two objects refer to the same object.

public static void
assertThrows(Assert.ThrowingRunnable
A function that is expected to throw an exception when invoked
runnable
)

Asserts that runnable throws an exception when invoked.

public static <
the expected type of the exception
T extends Throwable
>
void
assertThrows(Class<T>
the expected type of the exception
throwableClass
,
Assert.ThrowingRunnable
A function that is expected to throw an exception when invoked
runnable
)

Asserts that runnable throws an exception of type throwableClass when executed.

public static <
the expected type of the exception
T extends Throwable
>
void
assertThrows(String
fail message
message
,
Class<T>
the expected type of the exception
throwableClass
,
Assert.ThrowingRunnable
A function that is expected to throw an exception when invoked
runnable
)

Asserts that runnable throws an exception of type throwableClass when executed.

public static void
assertTrue(boolean
the condition to evaluate
condition
,
String
the assertion error message
message
)

Asserts that a condition is true.

public static void
assertTrue(boolean
the condition to evaluate
condition
)

Asserts that a condition is true.

private static boolean

Returns:

true if actualArray and expectedArray are the same, false otherwise. If references are different and arrays length are different AssertionError is thrown.
checkRefEqualityAndLength
(Object
array of elements
actualArray
,
Object
array of elements
expectedArray
,
String
the assertion error message
message
)

This methods check referential equality of given arguments as well as references length (assuming they are arrays).

public static <
the expected type of the exception
T extends Throwable
>
T

Returns:

The exception thrown by runnable
expectThrows
(Class<T>
the expected type of the exception
throwableClass
,
Assert.ThrowingRunnable
A function that is expected to throw an exception when invoked
runnable
)

Asserts that runnable throws an exception of type throwableClass when executed and returns the exception.

public static <
the expected type of the exception
T extends Throwable
>
T

Returns:

The exception thrown by runnable
expectThrows
(String
fail message
message
,
Class<T>
the expected type of the exception
throwableClass
,
Assert.ThrowingRunnable
A function that is expected to throw an exception when invoked
runnable
)

Asserts that runnable throws an exception of type throwableClass when executed and returns the exception.

public static void
fail(String
the assertion error message
message
,
Throwable
the original exception
realCause
)

Fails a test with the given message and wrapping the original exception.

public static void
fail(String
the assertion error message
message
)

Fails a test with the given message.

public static void
fail()

Fails a test with no message.

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
failSame(Object actual, Object expected, String message)

pack-priv static String
format(Object actual, Object expected, String message, boolean isAssertEquals)

private static String
getArrayNotEqualReason(Object actual, Object expected)

returns not equal reason or null if equal

private static String
getNotEqualDeepReason(Set<?> actual, Set<?> expected)

returns not equal deep reason or null if equal

private static String
getNotEqualDeepReason(Map<?, ?> actual, Map<?, ?> expected)

returns not equal deep reason or null if equal

private static String
getNotEqualReason(Collection<?> actual, Collection<?> expected)

returns not equal reason or null if equal

private static String
getNotEqualReason(Iterator<?> actual, Iterator<?> expected)

private static String
getNotEqualReason(Set<?> actual, Set<?> expected)

private static String
getNotEqualReason(Map<?, ?> actual, Map<?, ?> expected)

private static String
toString(Iterator<?> iterator)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait