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(...);

 

assertArrayEquals(byte[] expecteds, byte[] actuals) 

 : Asserts that two byte arrays are equal.

assertArrayEquals(char[] expecteds, char[] actuals) 

 : Asserts that two char arrays are equal.

assertArrayEquals(int[] expecteds, int[] actuals) 

 : Asserts that two int arrays are equal.

assertArrayEquals(long[] expecteds, long[] actuals) 

 : Asserts that two long arrays are equal.

assertArrayEquals(java.lang.Object[] expecteds, java.lang.Object[] actuals) 

 : Asserts that two object arrays are equal.

assertArrayEquals(short[] expecteds, short[] actuals) 

 : Asserts that two short arrays are equal.

assertArrayEquals(java.lang.String message, byte[] expecteds, byte[] actuals) 

 : Asserts that two byte arrays are equal.

assertArrayEquals(java.lang.String message, char[] expecteds, char[] actuals) 

 : Asserts that two char arrays are equal.

assertArrayEquals(java.lang.String message, int[] expecteds, int[] actuals) 

 : Asserts that two int arrays are equal.

assertArrayEquals(java.lang.String message, long[] expecteds, long[] actuals) 

 : Asserts that two long arrays are equal.

assertArrayEquals(java.lang.String message, java.lang.Object[] expecteds, java.lang.Object[] actuals) 

 : Asserts that two object arrays are equal.

assertArrayEquals(java.lang.String message, short[] expecteds, short[] actuals) 

 : Asserts that two short arrays are equal.

assertEquals(double expected, double actual) 

 : Deprecated. Use assertEquals(double expected, double actual, double epsilon) instead

assertEquals(double expected, double actual, double delta) 

 : Asserts that two doubles or floats are equal to within a positive delta.

assertEquals(long expected, long actual) 

 : Asserts that two longs are equal.

assertEquals(java.lang.Object[] expecteds, java.lang.Object[] actuals) 

 : Deprecated. use assertArrayEquals

assertEquals(java.lang.Object expected, java.lang.Object actual) 

 : Asserts that two objects are equal.

assertEquals(java.lang.String message, double expected, double actual) 

 : Deprecated. Use assertEquals(String message, double expected, double actual, double epsilon) instead

assertEquals(java.lang.String message, double expected, double actual, double delta) 

 : Asserts that two doubles or floats are equal to within a positive delta.

assertEquals(java.lang.String message, long expected, long actual) 

 : Asserts that two longs are equal.

assertEquals(java.lang.String message, java.lang.Object[] expecteds, java.lang.Object[] actuals) 

 : Deprecated. use assertArrayEquals

assertEquals(java.lang.String message, java.lang.Object expected, java.lang.Object actual) 

 : Asserts that two objects are equal.

assertFalse(boolean condition) 

 : Asserts that a condition is false.

assertFalse(java.lang.String message, boolean condition) 

 : Asserts that a condition is false.

assertNotNull(java.lang.Object object) 

 : Asserts that an object isn't null.

assertNotNull(java.lang.String message, java.lang.Object object) 

 : Asserts that an object isn't null.

assertNotSame(java.lang.Object unexpected, java.lang.Object actual) 

 : Asserts that two objects do not refer to the same object.

assertNotSame(java.lang.String message, java.lang.Object unexpected, java.lang.Object actual) 

 : Asserts that two objects do not refer to the same object.

assertNull(java.lang.Object object) 

 : Asserts that an object is null.

assertNull(java.lang.String message, java.lang.Object object) 

 : Asserts that an object is null.

assertSame(java.lang.Object expected, java.lang.Object actual) 

 : Asserts that two objects refer to the same object.

assertSame(java.lang.String message, java.lang.Object expected, java.lang.Object actual) 

 : Asserts that two objects refer to the same object.

assertThat(java.lang.String reason, T actual, org.hamcrest.Matcher<T> matcher) 

 : Asserts that actual satisfies the condition specified by matcher.

assertThat(T actual, org.hamcrest.Matcher<T> matcher) 

 : Asserts that actual satisfies the condition specified by matcher.

assertTrue(boolean condition) 

 : Asserts that a condition is true.

assertTrue(java.lang.String message, boolean condition) 

 : Asserts that a condition is true.

fail() 

 : Fails a test with no message.

fail(java.lang.String message) 

 : Fails a test with the given message.


http://junit.sourceforge.net/javadoc/org/junit/Assert.html


Posted by 솔라리스™

댓글을 달아 주세요