Class AssertionErrors
java.lang.Object
org.springframework.test.util.AssertionErrors
Test assertions that are independent of any third-party assertion library.
- Since:
- 3.2
- Author:
- Lukas Krecan, Arjen Poutsma, Sam Brannen
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionstatic voidAssert two objects are equal and raise anAssertionErrorotherwise.static voidassertFalse(String message, boolean condition) Assert the given condition isfalseand raise anAssertionErrorotherwise.static voidAssert two objects are not equal and raise anAssertionErrorotherwise.static voidassertNotNull(String message, @Nullable Object object) Assert that the given object is notnulland raise anAssertionErrorotherwise.static voidassertNull(String message, @Nullable Object object) Assert that the given object isnulland raise anAssertionErrorotherwise.static voidassertTrue(String message, boolean condition) Assert the given condition istrueand raise anAssertionErrorotherwise.static voidFail a test with the given message.static voidFail a test with the given message passing along expected and actual values to be appended to the message.
- 
Constructor Details- 
AssertionErrorspublic AssertionErrors()
 
- 
- 
Method Details- 
fail
- 
failFail 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> - Parameters:
- message- a message that describes the use case that failed
- expected- the expected value
- actual- the actual value
 
- 
assertTrueAssert the given condition istrueand raise anAssertionErrorotherwise.- Parameters:
- message- a message that describes the reason for the failure
- condition- the condition to test for
 
- 
assertFalseAssert the given condition isfalseand raise anAssertionErrorotherwise.- Parameters:
- message- a message that describes the reason for the failure
- condition- the condition to test for
- Since:
- 5.2.1
 
- 
assertNull@Contract("_, !null -> fail") public static void assertNull(String message, @Nullable Object object) Assert that the given object isnulland raise anAssertionErrorotherwise.- Parameters:
- message- a message that describes the reason for the failure
- object- the object to check
- Since:
- 5.2.1
 
- 
assertNotNull@Contract("_, null -> fail") public static void assertNotNull(String message, @Nullable Object object) Assert that the given object is notnulland raise anAssertionErrorotherwise.- Parameters:
- message- a message that describes the reason for the failure
- object- the object to check
- Since:
- 5.1.8
 
- 
assertEqualsAssert two objects are equal and raise anAssertionErrorotherwise.For example: assertEquals("Response header [" + name + "]", expected, actual);- Parameters:
- message- a message that describes the value being checked
- expected- the expected value
- actual- the actual value
- See Also:
 
- 
assertNotEqualspublic static void assertNotEquals(String message, @Nullable Object expected, @Nullable Object actual) Assert two objects are not equal and raise anAssertionErrorotherwise.For example: assertNotEquals("Response header [" + name + "]", expected, actual);- Parameters:
- message- a message that describes the value being checked
- expected- the expected value
- actual- the actual value
 
 
-