Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test worker @coroutine#1" io.mockative.MissingExpectationException: A function was called without a matching expectation #80

Open
Clemodd opened this issue Feb 11, 2024 · 0 comments

Comments

@Clemodd
Copy link

Clemodd commented Feb 11, 2024

Hi,

I have a problem with the coroutine test :(

When i do :
coEvery { splashScreenRepositoryMock.getToken() }.returns("blablabla")

I have this error : Exception in thread "Test worker @coroutine#1" io.mockative.MissingExpectationException: A function was called without a matching expectation.

An expectation was not given on the function:
    SplashScreenRepositoryMock.getToken()

Set up an expectation using:
    coEvery { splashScreenRepositoryMock.getToken() }
        .invokes { ... }

The following expectations were configured on the mock:

With :
coEvery { splashScreenRepositoryMock.getToken() }.invokes { "blablabla" }
Error : Overload resolution ambiguity. All these functions match.
public open fun invokes(block: suspend () → String?): Unit defined in io.mockative.SuspendResultBuilder
public final fun invokes(block: suspend (arguments: Array<Any?>) → String?): Unit defined in io.mockative.SuspendResultBuilder

But i stille have Exception in thread "Test worker @coroutine#1" io.mockative.MissingExpectationException: A function was called without a matching expectation. If a do :
coEvery { splashScreenRepositoryMock.getToken() }.invokes { -> "blablabla" }
coEvery { splashScreenRepositoryMock.getToken() }.invokes { arguments -> "Résultat avec ${arguments} " }

Here my repository :
interface SplashScreenRepository { suspend fun getToken(): String? suspend fun getEtape(): EtapeInscriptionEnum? }

Thank you for your help

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant