Skip to content

Provide callback mechanism when calls are made #34

@dalewking

Description

@dalewking

I would like to see a global call back mechanism to monitor calls to mocks and possibly even modify the behavior.

One use for this would be for logging. In complex cases where the SUT is interacting with multiple mocks it is helpful to debug to see what parameters were passed to the mock and what the mock is returning via logging.

It would also provide a way to handle my request in #20

As I see it at the minimum such a callback interface could look like:

    interface MockCallback {
        fun called(scope: FunctionScope, result: Result<Any>) : Result<Any>
        suspend fun calledSuspend(scope: FunctionScope, result: Result<Any>) : Result<Any> = called(scope, result)
    }

This lets you:

  • know when a mock is called and can log it
  • override the return value
  • add additional behavior such as blocking the return from the function

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions