public void testMethodGood() {
int[] arr = new int[]{};
final IndexOutOfBoundsException exception =
expectThrows(IndexOutOfBoundsException.class,
() -> {
int i = arr[2];
});
assertWithMessage("Invalid error message")
.that(exception.getMessage())
.isEqualTo("Index 2 out of bounds for length 0");
}
From #11315 (comment):
In the scope of this issue, we should:
getExpectedThrowablemethod in TestUtilsAssertions#assertThrowsto TestUtils onlyMatchXPathmodule introduced in Forbid usage of Truth'sStandardSubjectBuilder#failmethod. #11315We can consider using new feature mentioned at #11995 (review)