lucene-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Uwe Schindler (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (LUCENE-7009) Add expectThrows utility to LuceneTestCase
Date Thu, 04 Feb 2016 15:44:39 GMT

    [ https://issues.apache.org/jira/browse/LUCENE-7009?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15132461#comment-15132461
] 

Uwe Schindler commented on LUCENE-7009:
---------------------------------------

Very cool! Thanks :-)

I was about to add something similar for the well-known "success=false... success=true" try-catch-block
to oal.util.

> Add expectThrows utility to LuceneTestCase
> ------------------------------------------
>
>                 Key: LUCENE-7009
>                 URL: https://issues.apache.org/jira/browse/LUCENE-7009
>             Project: Lucene - Core
>          Issue Type: Bug
>            Reporter: Ryan Ernst
>            Assignee: Ryan Ernst
>             Fix For: master
>
>         Attachments: LUCENE-7009.patch
>
>
> In junit5, a neat assertion method is added which makes testing expected
> failures a little more straightforward. The block of code that is
> expected to throw is passed in with a lambda expression, and the caught
> exception returned for inspection. The usage looks something like this:
> {code}
> IOException e = expectThrows(IOException.class, () -> {
>     throw new IOException("some io error");
> });
> // assert stuff here about the exception
> {code}
> We should add this to LuceneTestCase until junit5 is available.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: dev-help@lucene.apache.org


Mime
View raw message