Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade of gradle from 5.4.1 to 5.5.0/5.5.1 results in test failures (inlining mockito with asm < 7.0) #101

Closed
ursjoss opened this issue Jul 12, 2019 · 4 comments · Fixed by #102
Assignees
Labels

Comments

@ursjoss
Copy link
Owner

ursjoss commented Jul 12, 2019

Bumping gradle from 5.4.1 to 5.5.1 results in failing tests, but only when run from gradle. Running the tests from IntellJ works fine.

ch.difty.scipamato.publ.persistence.paper.JooqPublicPaperServiceTest > findingByNumber_withRepoFindingRecord_returnsItWrappedAsOptional() FAILED
    org.mockito.exceptions.base.MockitoException
        Caused by: org.mockito.exceptions.base.MockitoException
            Caused by: java.lang.IllegalStateException
                Caused by: java.lang.UnsupportedOperationException

I presume it has to do with asm. But need to investigate. Currently rolled back the gradle-wrapper to 5.4.1.

@ursjoss ursjoss self-assigned this Jul 12, 2019
@ursjoss
Copy link
Owner Author

ursjoss commented Jul 13, 2019

ch.difty.scipamato.common.persistence.SortMapperTest > mapping_withEmptySortProperties_returnsEmptyList() FAILED
    org.mockito.exceptions.base.MockitoException: 
    Mockito cannot mock this class: class ch.difty.scipamato.common.persistence.paging.Sort.

    If you're not sure why you're getting this error, please report to the mailing list.


    Java               : 11
    JVM vendor name    : Oracle Corporation
    JVM vendor version : 11.0.4+7
    JVM name           : OpenJDK 64-Bit Server VM
    JVM version        : 11.0.4+7
    JVM info           : mixed mode
    OS name            : Linux
    OS version         : 5.2.0-arch2-1-ARCH


    You are seeing this disclaimer because Mockito is configured to create inlined mocks.
    You can learn about inline mocks and their limitations under item #39 of the Mockito class javadoc.

    Underlying exception : org.mockito.exceptions.base.MockitoException: Could not modify all classes [class java.lang.Object, interface java.io.Serializable, class ch.difty.scipamato.common.persistence.paging.Sort, interface java.lang.Iterable]

        Caused by:
        org.mockito.exceptions.base.MockitoException: Could not modify all classes [class java.lang.Object, interface java.io.Serializable, class ch.difty.scipamato.common.persistence.paging.Sort, interface java.lang.Iterable]

            Caused by:
            java.lang.IllegalStateException: 
            Byte Buddy could not instrument all classes within the mock's type hierarchy

            This problem should never occur for javac-compiled classes. This problem has been observed for classes that are:
             - Compiled by older versions of scalac
             - Classes that are part of the Android distribution

                Caused by:
                java.lang.UnsupportedOperationException: This feature requires ASM7

@ursjoss ursjoss changed the title Some tests using mockito fail with gradle 5.5.0/5.5.1 Upgrade of gradle from 5.4.1 to 5.5.0/5.5.1 results in test failures (inlining mockito with asm < 7.0) Jul 13, 2019
@ursjoss
Copy link
Owner Author

ursjoss commented Jul 13, 2019

gradle 5.5 introduced jacoco-0.8.4. See mockito/mockito#1717

@ursjoss
Copy link
Owner Author

ursjoss commented Jul 13, 2019

While mockito-3.0.2 should have the fix relevant to restore inlining, the issue highlighted a code-smell that I'd like to fix first if possible. Some tests were mocking lombok @value classes that are final classes. They should not be mocked at all, sometimes they are just dummies and can be instantiated easily. Trying to get rid of the need for inlining where possible first.

@ursjoss
Copy link
Owner Author

ursjoss commented Jul 13, 2019

I have been able to remove the need for inlining in most cases. However mocking jooq records don't behave as I'd expect without inlining. I resorted to actually disabling some tests in following test classes for the time being:

  • JooqCodeRepoTest
  • JooqCodeClassRepoTest
  • JooqKeywordRepoTest

I'll open a ticket to re-activate them once we have mockito-3.0.2 or later in the project (probably waiting for spring-boot-2.2 to pull this in.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
1 participant