As provided in your answer, it's a good approach. In addition to this:
You could wrap the function expectException
into a new Annotation, called ExpectedException
.
An annotated method would look like this:
@Test
@ExpectedException(class=WrapperException.class, message="Exception Message", causeException)
public void testAnExceptionWrappingFunction() {
//whatever you test
}
This way would be more readable, but it's exactly the same approach.
Another reason is: I like Annotations :)
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…