Skip to content

How to mock a suspend function on an existing mock object? #311

@Moes81

Description

@Moes81

I have mock A built and given to me. Now, I need to mock a suspend API to return a value foo.

Example:

@Inject lateinit var mockA: A // using dagger to provide mocks configured in a separate module.

@Test
fun test1() = runBlocking {
    // how do i mock a suspend method on mockA?
}

Originally posted by @andrewborba10 in #269 (comment)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions