Thursday

Basic Assert in Junit - Beginner


  • Assertions

assertEquals()
assertEquals("something", result);

assertTrue()/ assertFalse()
assertTrue (oMyClass.myMethod());
assertFalse(oMyClass.myMethod());


assertNull() / assertNotNull()
assertNull(oMyClass.myMethod());
assertNotNull(oMyClass.myMethod());

assertSame()/assertNotSame()
assertNotSame(oMyClass1.myMethod(),
oMyClass2.myMethod());


assertArrayEquals()

String[] expectedArray = {"one", "two", "three"};
String[] actualArray =  oMyClass.myMethod();
assertArrayEquals(expectedArray,actualArray );


No comments:

Post a Comment