Uploaded image for project: 'Lucene - Core'
  1. Lucene - Core
  2. LUCENE-7009

Add expectThrows utility to LuceneTestCase

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 6.0
    • Component/s: None
    • Labels:
      None
    • Lucene Fields:
      New

      Description

      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:

      IOException e = expectThrows(IOException.class, () -> {
          throw new IOException("some io error");
      });
      // assert stuff here about the exception
      

      We should add this to LuceneTestCase until junit5 is available.

        Activity

        Hide
        rjernst Ryan Ernst added a comment -

        Patch.

        Show
        rjernst Ryan Ernst added a comment - Patch.
        Hide
        jira-bot ASF subversion and git services added a comment -

        Commit 732b8fb3b9d0e1a215c0f02b99a0c8847ecf7039 in lucene-solr's branch refs/heads/master from Ryan Ernst
        [ https://git-wip-us.apache.org/repos/asf?p=lucene-solr.git;h=732b8fb ]

        LUCENE-7009: Add expectThrows utility to LuceneTestCase

        Show
        jira-bot ASF subversion and git services added a comment - Commit 732b8fb3b9d0e1a215c0f02b99a0c8847ecf7039 in lucene-solr's branch refs/heads/master from Ryan Ernst [ https://git-wip-us.apache.org/repos/asf?p=lucene-solr.git;h=732b8fb ] LUCENE-7009 : Add expectThrows utility to LuceneTestCase
        Hide
        thetaphi Uwe Schindler added a comment -

        Very cool! Thanks

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

        Show
        thetaphi Uwe Schindler added a comment - Very cool! Thanks I was about to add something similar for the well-known "success=false... success=true" try-catch-block to oal.util.
        Hide
        jira-bot ASF subversion and git services added a comment -

        Commit 732b8fb3b9d0e1a215c0f02b99a0c8847ecf7039 in lucene-solr's branch refs/heads/lucene-6835 from Ryan Ernst
        [ https://git-wip-us.apache.org/repos/asf?p=lucene-solr.git;h=732b8fb ]

        LUCENE-7009: Add expectThrows utility to LuceneTestCase

        Show
        jira-bot ASF subversion and git services added a comment - Commit 732b8fb3b9d0e1a215c0f02b99a0c8847ecf7039 in lucene-solr's branch refs/heads/lucene-6835 from Ryan Ernst [ https://git-wip-us.apache.org/repos/asf?p=lucene-solr.git;h=732b8fb ] LUCENE-7009 : Add expectThrows utility to LuceneTestCase

          People

          • Assignee:
            rjernst Ryan Ernst
            Reporter:
            rjernst Ryan Ernst
          • Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development