Uploaded image for project: 'Solr'
  1. Solr
  2. SOLR-11606

Mockito does not work with newer Java versions -> disable tests automatically when no working Mockito

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • None
    • 7.2, 8.0
    • Tests

    Description

      When running Solr's tests with Java versions that are not supported by the Mockito mocking library, it fails with an error message.

      We should disable the tests, if the underlying Mockito version does not allow to mock classes, because the Java version is too new. There is already and issue open at ByteBuddy that is the root cause: https://github.com/raphw/byte-buddy/issues/370 and https://github.com/mockito/mockito/issues/1243

      The idea here is to use ByteBuddy's ClassFileVersion class to check if mocking is supported. This adds a new method to SolrTestCaseJ4: assumeWorkingMockito()

      Tests that use the Mockito library should add this assume to their tests, to disable them if the mocking is not supported. Instead of using a Java version test, we do this with ByteBuddy, because this is more dynamic (if we update Mockito so it works with newer Java versions, it is automatically working).

      At the same time, we should update Mockito/ByteBuddy ASAP when a new version is available.

      Attachments

        1. SOLR-11606.patch
          22 kB
          Uwe Schindler
        2. SOLR-11606.patch
          20 kB
          Uwe Schindler

        Activity

          People

            uschindler Uwe Schindler
            uschindler Uwe Schindler
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: