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.
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
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):Since
mocker
is public on TestsWithMocks, it seems fair to me to make the shortcut methods public too.