📜  junit 5 断言异常消息 - Java 代码示例

📅  最后修改于: 2022-03-11 14:52:40.188000             🧑  作者: Mango

代码示例1
Throwable exceptionThatWasThrown = assertThrows(NullPointerException.class, () -> {
    codeThatThrows;
});

assertThat(exceptionThatWasThrown.getMessage(), equalTo("Message I expected to be thrown"));