Jason Gerlowski created SOLR-12555:
--------------------------------------

             Summary: Replace try-fail-catch test patterns
                 Key: SOLR-12555
                 URL: https://issues.apache.org/jira/browse/SOLR-12555
             Project: Solr
          Issue Type: Test
      Security Level: Public (Default Security Level. Issues are Public)
          Components: Tests
    Affects Versions: master (8.0)
            Reporter: Jason Gerlowski
            Assignee: Jason Gerlowski


I recently added some test code through SOLR-12427 which used the following 
test anti-pattern:

{code}
try {
    actionExpectedToThrowException();
    fail("I expected this to throw an exception, but it didn't");
catch (Exception e) {
    assertOnThrownException(e);
}
{code}

Hoss (rightfully) objected that this should instead be written using the 
formulation below, which is clearer and more concise.

{code}
SolrException e = expectThrows(() -> {...});
{code}

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.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to