| We have this pattern in several places in the code, in particular when we cannot use @Test.expected or the ExpectedException rule:
try {
<some code that is expected to fail>
Assert.fail( "code did not fail as expected");
}
catch (Exception e) {
assertThat( e )
.isInstanceOf( SearchException.class )
.hasMessageContaining( "some message" );
}
Unfortunately, this pattern is very error-prone, as it's very easy to forget the Assert.fail call. And we did forget it in several places (though not all...). Let's find a better way to achieve this, once that is more error-proof. |