kosi-libs / MocKMP

A mocking processor for Kotlin Multiplatform
https://kosi-libs.org/mockmp
MIT License
189 stars 12 forks source link

Expose every {} publicly #12

Closed glureau closed 2 years ago

glureau commented 2 years ago

I'm trying to define some common mocking methods that I use in many tests. I'd like to be able to write something like

fun TestsWithMocks.defaultMockListener(mockListener: Listener) {
    every { mockListener.didStart(isAny(), isAny()) } returns Unit
    every { mockListener.didProgress(isAny(), isAny()) } returns Unit
    // ....

But actually the every method is protected so I can't use it that easily. A workaround can be to use the mocker (defined publicly):

fun TestsWithMocks.defaultMockListener(mockListener: Listener) {
    mocker.every { mockListener.didStart(isAny(), isAny()) } returns Unit
    mocker.every { mockListener.didProgress(isAny(), isAny()) } returns Unit
    // ....

Since mocker is public on TestsWithMocks, it seems fair to me to make the shortcut methods public too.

SalomonBrys commented 2 years ago

Fixed in 1.4.0.

glureau commented 2 years ago

Thank you!