Skip to main content

JUnit 5

Liens

https://www.baeldung.com/junit-5 (base)

Test Exceptions

 Exception exception = assertThrows(IOException.class, () -> {
Encrypting.setKeyOnFile(null,md5File.toString());
Encrypting.setKeyOnFile(null,null);
});
String expectedMessage = "La clé ne doit pas être null";
String actualMessage = exception.getMessage();

exception = assertThrows(NullPointerException.class, () -> {
Encrypting.setKeyOnFile(key,null);
Encrypting.getKeyFromFile(null);
});
assertNotNull(exception);