????????????дBDD????????

@Test
public void shouldGetExceptionWhenAgeLessThan0() {
// given
Person person = new Person();
// when
when(person).setAge(-1);
// then
then(caughtException())
.isInstanceOf(IllegalArgumentException.class)
.hasMessage("age is invalid")
.hasNoCause();
}
??????????Hamcrest??????????????catch-exception??????????Matcher API??
@Test
public void shouldGetExceptionWhenAgeLessThan0() {
// given
Person person = new Person();
// when
when(person).setAge(-1);
// then
assertThat(caughtException()?? allOf(
instanceOf(IllegalArgumentException.class)
?? hasMessage("age is invalid")
??hasNoCause()));
}
??????????????????????????????