谁能告诉我如何使用断言抛出有几个例外?
对于ex,这里有一个类:
protected void checkViolation(Set<ConstraintViolation<EcritureComptable>> vViolations) throws FunctionalException {
if (!vViolations.isEmpty()) {
throw new FunctionalException("L'écriture comptable ne respecte pas les règles de gestion.",
new ConstraintViolationException(
"L'écriture comptable ne respecte pas les contraintes de validation",
vViolations));
}
}
和我的测试方法:
@Test
void checkViolation(){
comptabiliteManager = spy(ComptabiliteManagerImpl.class);
when(vViolations.isEmpty()).thenReturn(false);
assertThrows( ConstraintViolationException.class, () ->comptabiliteManager.checkViolation(vViolations), "a string should be provided!");
}
我想匹配方法并完全抛出 ConstraintViolationException 和 FunctionalException
有什么想法吗?
白猪掌柜的
慕村225694
相关分类