类 AssertionErrors
- java.lang.Object
- org.springframework.test.util.AssertionErrors
public abstract class AssertionErrors extends Object
Test assertions that are independent of any third-party assertion library.- 从以下版本开始:
- 3.2
- 作者:
- Lukas Krecan, Arjen Poutsma, Sam Brannen
构造器概要
构造器 构造器 说明 AssertionErrors()
方法概要
所有方法 静态方法 具体方法 修饰符和类型 方法 说明 static void
assertEquals(String message, Object expected, Object actual)
Assert two objects are equal and raise anAssertionError
otherwise.static void
assertFalse(String message, boolean condition)
Assert the given condition isfalse
and raise anAssertionError
otherwise.static void
assertNotEquals(String message, Object expected, Object actual)
Assert two objects are not equal and raise anAssertionError
otherwise.static void
assertNotNull(String message, Object object)
Assert that the given object is notnull
and raise anAssertionError
otherwise.static void
assertNull(String message, Object object)
Assert that the given object isnull
and raise anAssertionError
otherwise.static void
assertTrue(String message, boolean condition)
Assert the given condition istrue
and raise anAssertionError
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.
构造器详细资料
AssertionErrors
public AssertionErrors()
方法详细资料
fail
public static void fail(String message)
Fail a test with the given message.- 参数:
message
- a message that describes the reason for the failure
fail
public static void fail(String message, @Nullable Object expected, @Nullable Object actual)
Fail a test with the given message passing along expected and actual values to be appended to the message.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 value
assertTrue
public static void assertTrue(String message, boolean condition)
Assert the given condition istrue
and raise anAssertionError
otherwise.- 参数:
message
- a message that describes the reason for the failurecondition
- the condition to test for
assertFalse
public static void assertFalse(String message, boolean condition)
Assert the given condition isfalse
and raise anAssertionError
otherwise.- 参数:
message
- a message that describes the reason for the failurecondition
- the condition to test for- 从以下版本开始:
- 5.2.1
assertNull
public static void assertNull(String message, @Nullable Object object)
Assert that the given object isnull
and raise anAssertionError
otherwise.- 参数:
message
- a message that describes the reason for the failureobject
- the object to check- 从以下版本开始:
- 5.2.1
assertNotNull
public static void assertNotNull(String message, @Nullable Object object)
Assert that the given object is notnull
and raise anAssertionError
otherwise.- 参数:
message
- a message that describes the reason for the failureobject
- the object to check- 从以下版本开始:
- 5.1.8
assertEquals
public static void assertEquals(String message, @Nullable Object expected, @Nullable Object actual)
Assert two objects are equal and raise anAssertionError
otherwise.For example:
assertEquals("Response header [" + name + "]", expected, actual);
- 参数:
message
- a message that describes the value being checkedexpected
- the expected valueactual
- the actual value- 另请参阅:
fail(String, Object, Object)
assertNotEquals
public static void assertNotEquals(String message, @Nullable Object expected, @Nullable Object actual)
Assert two objects are not equal and raise anAssertionError
otherwise.For example:
assertNotEquals("Response header [" + name + "]", expected, actual);
- 参数:
message
- a message that describes the value being checkedexpected
- the expected valueactual
- the actual value