public abstract class AssertionErrors extends Object
Constructor and Description |
---|
AssertionErrors() |
Modifier and Type | Method and Description |
---|---|
static void |
assertEquals(String message,
Object expected,
Object actual)
Assert two objects are equal and raise an
AssertionError otherwise. |
static void |
assertNotEquals(String message,
Object expected,
Object actual)
Assert two objects are not equal and raise an
AssertionError otherwise. |
static void |
assertNotNull(String message,
Object object)
Assert that the given object is not
null and raise an
AssertionError otherwise. |
static void |
assertTrue(String message,
boolean condition)
Assert the given condition is
true and raise an
AssertionError otherwise. |
static void |
fail(String message)
Fail a test with the given message.
|
static void |
fail(String message,
Object expected,
Object actual)
Fail a test with the given message passing along expected and actual
values to be appended to the message.
|
public static void fail(String message)
message
- a message that describes the reason for the failurepublic static void fail(String message, @Nullable Object expected, @Nullable Object actual)
For example given:
String name = "Accept"; String expected = "application/json"; String actual = "text/plain"; fail("Response header [" + name + "]", expected, actual);
The resulting message is:
Response header [Accept] expected:<application/json> but was:<text/plain>
message
- a message that describes the use case that failedexpected
- the expected valueactual
- the actual valuepublic static void assertTrue(String message, boolean condition)
true
and raise an
AssertionError
otherwise.message
- a message that describes the reason for the failurecondition
- the condition to test forpublic static void assertNotNull(String message, @Nullable Object object)
null
and raise an
AssertionError
otherwise.message
- a message that describes the reason for the failureobject
- the object to checkpublic static void assertEquals(String message, @Nullable Object expected, @Nullable Object actual)
AssertionError
otherwise.
For example:
assertEquals("Response header [" + name + "]", expected, actual);
message
- a message that describes the value being checkedexpected
- the expected valueactual
- the actual valuefail(String, Object, Object)
public static void assertNotEquals(String message, @Nullable Object expected, @Nullable Object actual)
AssertionError
otherwise.
For example:
assertNotEquals("Response header [" + name + "]", expected, actual);
message
- a message that describes the value being checkedexpected
- the expected valueactual
- the actual value