4

I would like to mock the following function:

private fun <T> updateItemInDb(id: Long, column: String, data: T)

which is invoked in the following way by my class:

updateItemInDb(it, DB_POS, i), where it is a Long, DB_POS is String and i is an Int.

I want the function to just run without doing anything. I tried the following in my unit test:

1) every { adapter["updateItemInDb"](any<Long>(), any<String>(), any<Int>()) } just Runs

This gives me a type mismatch error: required MockKStubScope<Unit>, found MockKStubScope<Any?>

2) every { adapter["updateItemInDb"](any<Long>(), any<String>(), any<Int>()) } answers { }

This fails at runtime with io.mockk.MockKException: can't find function updateItemInDb(-1078155520644112829, -d008fa83c4f49c0, 843241211) for dynamic call

AlexSee
  • 322
  • 3
  • 16
  • 1
    I created an issue [#70](https://github.com/oleksiyp/mockk/issues/70) for it. – oleksiyp May 03 '18 at 14:57
  • 1
    Version 1.7.16 should fix this issue. Please check and close GH issue [#70](https://github.com/oleksiyp/mockk/issues/70) if it is working. After you close (if so) I will write an answer to this question. – oleksiyp May 06 '18 at 21:19

1 Answers1

2

Now yes. Generic private functions was fixed since 1.7.16

oleksiyp
  • 2,659
  • 19
  • 15