像 我试图写测试用例这种情况下,在此我期待SQLIntegrityConstraintViolationException,我试图断言使用断言相同的是通过抛出,但我得到断言错误的期待码养Throwable。如何解决这个问题,有人可以帮我解决这个问题。
我正在使用JUnit5.
如屏幕截图所示,该方法在应用异常情况后似乎没有运行
@Test
public void insertUpdateDatatypesizecountValidation() throws Exception {
id = 0;
StandAloneConnection standAloneConnection = new StandAloneConnection(
propertyFile);
Connection conn = standAloneConnection.getConnection();
assertThatThrownBy(() -> called.datas(conn, id))
.hasMessage("Column 'ID' cannot be null")
.isInstanceOf(SQLIntegrityConstraintViolationException.class);
}
Run Code Online (Sandbox Code Playgroud)