JUnit provides a variety of assertion methods in the org.junit.Assert
class (or in later versions, you can use org.junit.jupiter.api.Assertions
in JUnit 5). These assertions help you check whether the expected result of a test matches the actual result. Here are some common and useful JUnit assertions:
assertEquals:
assertEquals(expected, actual);
assertNotEquals:
assertNotEquals(notExpected, actual);
assertTrue / assertFalse:
assertTrue(condition);
assertFalse(condition);
assertThrows (JUnit 5):
assertThrows(Exception.class, () -> {
// Code that should throw an exception
});