Details
-
Test
-
Status: Resolved
-
Trivial
-
Resolution: Done
-
8.0
-
None
-
None
Description
I recently added some test code through SOLR-12427 which used the following test anti-pattern:
try { actionExpectedToThrowException(); fail("I expected this to throw an exception, but it didn't"); catch (Exception e) { assertOnThrownException(e); }
Hoss (rightfully) objected that this should instead be written using the formulation below, which is clearer and more concise.
SolrException e = expectThrows(() -> {...});
We should remove many of these older formulations where it makes sense. Many of them were written before expectThrows was introduced, and having the old style assertions around makes it easier for them to continue creeping in.