Skip to content

any() doesn't seem to work with latest Mockito (2.0.94-beta) #57

@unintelligible

Description

@unintelligible

Mockito have recently refactored the MockUtils class to be a static utility class (with a private constructor):

mockito/mockito@3fe3b62#diff-321079f7242b016035f4577222dfe7a3R26

However, mockito-kotlin tries to instantiate an instance of it - see CreateInstance.kt line 180:

return MockUtil().createMock(creationSettings).apply...

This causes the following runtime error when executing a test which calls the any() method:

java.lang.IllegalAccessError: tried to access method org.mockito.internal.util.MockUtil.<init>()V from class com.nhaarman.mockito_kotlin.CreateInstanceKt
    at com.nhaarman.mockito_kotlin.CreateInstanceKt.uncheckedMock(CreateInstance.kt:180)
    at com.nhaarman.mockito_kotlin.CreateInstanceKt.createInstance(CreateInstance.kt:58)

The fix should just be to call the static method instead - MockUtil.createMock(creationSettings).apply...

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions