kosi-libs/MocKMP

Is any special step should be taken to mock vararg functions?

motorro opened this issue · 2 comments

Hello!

I'm trying to mock the interface with the function that has a vararg argument. Is there anything special should be done to do it or is it not supported?

The interface I try to mock:

interface ResourceWrapper {
    /**
     * Returns a resource string
     */
    fun getString(resId: StringResource, vararg args: Any): String
}

Generated file:

internal class MockResourceWrapper(
  private val mocker: Mocker,
) : ResourceWrapper {
    public override fun getString(resId: StringResource, args: Any): String =
      this.mocker.register(this, "getString(dev.icerock.moko.resources.StringResource, kotlin.Any)",
      resId, args)
}

The overriden function doesn't have a vararg modifier so I get a compilation error

Vararg arguments are not supported yet.
I'll work on those for next release 👍

Fix released in v1.14.0.