Package org.springframework.test.util
Class AssertionErrors
- java.lang.Object
- org.springframework.test.util.AssertionErrors
public abstract class AssertionErrors extends Object
JUnit independent assertion class.- Since:
- 3.2
- Author:
- Lukas Krecan, Arjen Poutsma
Constructor Summary
Constructors Constructor Description AssertionErrors()
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static voidassertEquals(String message, Object expected, Object actual)Assert two objects are equal raise anAssertionErrorif not.static voidassertTrue(String message, boolean condition)Assert the given condition istrueand raise anAssertionErrorif it is not.static voidfail(String message)Fails a test with the given message.static voidfail(String message, Object expected, Object actual)Fails a test with the given message passing along expected and actual values to be added to the message.
Constructor Detail
AssertionErrors
public AssertionErrors()
Method Detail
fail
public static void fail(String message)
Fails a test with the given message.- Parameters:
message- describes the reason for the failure
fail
public static void fail(String message, Object expected, Object actual)
Fails a test with the given message passing along expected and actual values to be added to the message.For example given:
assertEquals("Response header [" + name + "]", actual, expected);The resulting message is:
Response header [Accept] expected:<application/json> but was:<text/plain>
- Parameters:
message- describes the value that failed the matchexpected- expected valueactual- actual value
assertTrue
public static void assertTrue(String message, boolean condition)
Assert the given condition istrueand raise anAssertionErrorif it is not.- Parameters:
message- the messagecondition- the condition to test for
assertEquals
public static void assertEquals(String message, Object expected, Object actual)
Assert two objects are equal raise anAssertionErrorif not.For example:
assertEquals("Response header [" + name + "]", actual, expected);- Parameters:
message- describes the value being checkedexpected- the expected valueactual- the actual value