Skip to content

Attempting to verify mocked calls with a class that has a string array parameter in its constructor throws UnsupportedOperationException #75

@xiphirx

Description

@xiphirx

Hi,

I'm running into an issue where I'm trying to verify mocked calls on an object with the use of eq.

My test looks like:

data class Foo(val baz: Array<String>)

val bar = Foo(arrayOf("a", "b"))

@Test fun test() {
    verify(mock).method(eq(bar))
}

This fails with

java.lang.UnsupportedOperationException: Cannot create a generic array for Array. Use createArrayInstance() or anyArray() instead.
    at com.nhaarman.mockito_kotlin.CreateInstanceKt.toArrayInstance(CreateInstance.kt:124)
    at com.nhaarman.mockito_kotlin.CreateInstanceKt.createInstance(CreateInstance.kt:61)
    at com.nhaarman.mockito_kotlin.CreateInstanceKt.createNullableInstance(CreateInstance.kt:162)
    at com.nhaarman.mockito_kotlin.CreateInstanceKt.newInstance(CreateInstance.kt:137)
    at com.nhaarman.mockito_kotlin.CreateInstanceKt.createInstance(CreateInstance.kt:63)

Is there something that can be done about this?

Metadata

Metadata

Assignees

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