Assertion
All the assertions are in the Assert class.
public class Assert extends java.lang.Object
This class provides a set of assertion methods, useful for writing tests. Only failed assertions are recorded. Some of the important methods of Assert class are as follows −
Sr.No. | Methods & Description |
---|
1 | void assertEquals(boolean expected, boolean actual) Checks that two primitives/objects are equal. |
2 | void assertTrue(boolean condition) Checks that a condition is true. |
3 | void assertFalse(boolean condition) Checks that a condition is false. |
4 | void assertNotNull(Object object) Checks that an object isn't null. |
5 | void assertNull(Object object) Checks that an object is null. |
6 | void assertSame(object1, object2) The assertSame() method tests if two object references point to the same object. |
7 | void assertNotSame(object1, object2) The assertNotSame() method tests if two object references do not point to the same object. |
8 | void assertArrayEquals(expectedArray, resultArray); The assertArrayEquals() method will test whether two arrays are equal to each other. |