Skip to content

Commit

Permalink
✅ Add a tests for exception message
Browse files Browse the repository at this point in the history
Signed-off-by: Marcus Fihlon <[email protected]>
  • Loading branch information
McPringle committed Nov 3, 2024
1 parent 2a66a5b commit 5a558bb
Showing 1 changed file with 13 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,25 @@

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertInstanceOf;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertThrows;

class SessionImportExceptionTest {

@Test
@SuppressWarnings("java:S5778")
void testException() {
void testExceptionWithMessage() {
final var exception = assertThrows(SessionImportException.class, () -> {
throw new SessionImportException("Session Import Exception");
});
assertInstanceOf(SessionImportException.class, exception);
assertEquals("Session Import Exception", exception.getMessage());
assertNull(exception.getCause());
}

@Test
@SuppressWarnings("java:S5778")
void testExceptionWithMessageAndCause() {
final var exception = assertThrows(SessionImportException.class, () -> {
throw new SessionImportException("Session Import Exception", new RuntimeException("Runtime Exception"));
});
Expand Down

0 comments on commit 5a558bb

Please sign in to comment.