You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@lucene.apache.org by "Munendra S N (JIRA)" <ji...@apache.org> on 2019/07/27 05:23:00 UTC
[jira] [Commented] (SOLR-12555) Replace try-fail-catch test
patterns
[ https://issues.apache.org/jira/browse/SOLR-12555?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16894275#comment-16894275 ]
Munendra S N commented on SOLR-12555:
-------------------------------------
[^SOLR-12555.patch]
For all other packages
> Replace try-fail-catch test patterns
> ------------------------------------
>
> Key: SOLR-12555
> URL: https://issues.apache.org/jira/browse/SOLR-12555
> Project: Solr
> Issue Type: Test
> Components: Tests
> Affects Versions: 8.0
> Reporter: Jason Gerlowski
> Assignee: Jason Gerlowski
> Priority: Trivial
> Attachments: SOLR-12555-sorted-by-package.txt, SOLR-12555.patch, SOLR-12555.patch, SOLR-12555.patch, SOLR-12555.txt
>
> Time Spent: 4h 20m
> Remaining Estimate: 0h
>
> 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.14#76016)
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: dev-help@lucene.apache.org