I wonder whather it's possible to run a lambda function passed as a parameter to a mocked function. And run it whenever the mocked method is called.
I am using Mockk and I imagine the code to be something like this:
class DataManager {
fun submit(lambda: (Int) => Unit) { ... }
}
...
val mock = mockk<DataManager>()
every { mock.submit(lambda = any()) }.run { lambda(5) }
In my real implementation the datamanager calls a server and runs the lambda as a callback when it recieves a successful response. The lambda happens to be a private method of the class under test.