We're updating the issue view to help you get more done. 

Use a safe pattern to check for exception in tests

Description

We have this pattern in several places in the code, in particular when we cannot use @Test.expected or the ExpectedException rule:

1 2 3 4 5 6 7 8 9 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.

Environment

None

Status

Assignee

Yoann Rodière

Reporter

Yoann Rodière

Labels

None

Suitable for new contributors

None

Feedback Requested

None

Components

Fix versions

Priority

Major