Assert in java package
A set of assertion methods useful for writing tests. Only failed assertions are recorded. These methods can be used directly: Assert.assertEquals(. ) , however, they read better if they are referenced through static import:
import static org.junit.Assert.*; . assertEquals(. );
Constructor Summary | |
---|---|
protected | Assert () Protect constructor since it is a static only class |
Method Summary | ||
---|---|---|
static void | assertArrayEquals (boolean[] expecteds, boolean[] actuals) Asserts that two boolean arrays are equal. | |
static void | assertArrayEquals (byte[] expecteds, byte[] actuals) Asserts that two byte arrays are equal. | |
static void | assertArrayEquals (char[] expecteds, char[] actuals) Asserts that two char arrays are equal. | |
static void | assertArrayEquals (double[] expecteds, double[] actuals, double delta) Asserts that two double arrays are equal. | |
static void | assertArrayEquals (float[] expecteds, float[] actuals, float delta) Asserts that two float arrays are equal. | |
static void | assertArrayEquals (int[] expecteds, int[] actuals) Asserts that two int arrays are equal. | |
static void | assertArrayEquals (long[] expecteds, long[] actuals) Asserts that two long arrays are equal. | |
static void | assertArrayEquals (Object[] expecteds, Object[] actuals) Asserts that two object arrays are equal. | |
static void | assertArrayEquals (short[] expecteds, short[] actuals) Asserts that two short arrays are equal. | |
static void | assertArrayEquals (String message, boolean[] expecteds, boolean[] actuals) Asserts that two boolean arrays are equal. | |
static void | assertArrayEquals (String message, byte[] expecteds, byte[] actuals) Asserts that two byte arrays are equal. | |
static void | assertArrayEquals (String message, char[] expecteds, char[] actuals) Asserts that two char arrays are equal. | |
static void | assertArrayEquals (String message, double[] expecteds, double[] actuals, double delta) Asserts that two double arrays are equal. | |
static void | assertArrayEquals (String message, float[] expecteds, float[] actuals, float delta) Asserts that two float arrays are equal. | |
static void | assertArrayEquals (String message, int[] expecteds, int[] actuals) Asserts that two int arrays are equal. | |
static void | assertArrayEquals (String message, long[] expecteds, long[] actuals) Asserts that two long arrays are equal. | |
static void | assertArrayEquals (String message, Object[] expecteds, Object[] actuals) Asserts that two object arrays are equal. | |
static void | assertArrayEquals (String message, short[] expecteds, short[] actuals) Asserts that two short arrays are equal. | |
static void | assertEquals (double expected, double actual) Deprecated. Use assertEquals(double expected, double actual, double delta) instead | |
static void | assertEquals (double expected, double actual, double delta) Asserts that two doubles are equal to within a positive delta. | |
static void | assertEquals (float expected, float actual, float delta) Asserts that two floats are equal to within a positive delta. | |
static void | assertEquals (long expected, long actual) Asserts that two longs are equal. | |
static void | assertEquals (Object[] expecteds, Object[] actuals) Deprecated. use assertArrayEquals | |
static void | assertEquals (Object expected, Object actual) Asserts that two objects are equal. | |
static void | assertEquals (String message, double expected, double actual) Deprecated. Use assertEquals(String message, double expected, double actual, double delta) instead | |
static void | assertEquals (String message, double expected, double actual, double delta) Asserts that two doubles are equal to within a positive delta. | |
static void | assertEquals (String message, float expected, float actual, float delta) Asserts that two floats are equal to within a positive delta. | |
static void | assertEquals (String message, long expected, long actual) Asserts that two longs are equal. | |
static void | assertEquals (String message, Object[] expecteds, Object[] actuals) Deprecated. use assertArrayEquals | |
static void | assertEquals (String message, Object expected, Object actual) Asserts that two objects are equal. | |
static void | assertFalse (boolean condition) Asserts that a condition is false. | |
static void | assertFalse (String message, boolean condition) Asserts that a condition is false. | |
static void | assertNotEquals (double unexpected, double actual, double delta) Asserts that two doubles are not equal to within a positive delta. | |
static void | assertNotEquals (float unexpected, float actual, float delta) Asserts that two floats are not equal to within a positive delta. | |
static void | assertNotEquals (long unexpected, long actual) Asserts that two longs are not equals. | |
static void | assertNotEquals (Object unexpected, Object actual) Asserts that two objects are not equals. | |
static void | assertNotEquals (String message, double unexpected, double actual, double delta) Asserts that two doubles are not equal to within a positive delta. | |
static void | assertNotEquals (String message, float unexpected, float actual, float delta) Asserts that two floats are not equal to within a positive delta. | |
static void | assertNotEquals (String message, long unexpected, long actual) Asserts that two longs are not equals. | |
static void | assertNotEquals (String message, Object unexpected, Object actual) Asserts that two objects are not equals. | |
static void | assertNotNull (Object object) Asserts that an object isn’t null. | |
static void | assertNotNull (String message, Object object) Asserts that an object isn’t null. | |
static void | assertNotSame (Object unexpected, Object actual) Asserts that two objects do not refer to the same object. | |
static void | assertNotSame (String message, Object unexpected, Object actual) Asserts that two objects do not refer to the same object. | |
static void | assertNull (Object object) Asserts that an object is null. | |
static void | assertNull (String message, Object object) Asserts that an object is null. | |
static void | assertSame (Object expected, Object actual) Asserts that two objects refer to the same object. | |
static void | assertSame (String message, Object expected, Object actual) Asserts that two objects refer to the same object. | |
static
| assertThat (String reason, T actual, Matcher matcher) Deprecated. use org.hamcrest.MatcherAssert.assertThat() | |
static
| assertThat (T actual, Matcher matcher) Deprecated. use org.hamcrest.MatcherAssert.assertThat() | |
static
| assertThrows (Class expectedThrowable, ThrowingRunnable runnable) Asserts that runnable throws an exception of type expectedThrowable when executed. | |
static
| assertThrows (String message, Class expectedThrowable, ThrowingRunnable runnable) Asserts that runnable throws an exception of type expectedThrowable when executed. | |
static void | assertTrue (boolean condition) Asserts that a condition is true. | |
static void | assertTrue (String message, boolean condition) Asserts that a condition is true. | |
static void | fail () Fails a test with no message. | |
static void | fail (String message) Fails a test with the given message. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Assert
assertTrue
public static void assertTrue(String message, boolean condition)
Parameters: message — the identifying message for the AssertionError ( null okay) condition — condition to be checked