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

@InjectMock(relaxUnitFun = true) does not seem to work for suspending functions #236

Open
marvedly opened this issue Sep 29, 2023 · 2 comments

Comments

@marvedly
Copy link

Hi!

I noticed that @InjectMock(relaxUnitFun = true) does not seem to work for suspending functions that return Unit. Is that intended by design or a bug? The test passes well when I configure @InjectMock(relaxed = true) instead.

Thanks!

@jogerj
Copy link

jogerj commented Dec 20, 2023

Could not reproduce on 2.1.0. Test passed.

testImplementation("io.quarkiverse.mockk:quarkus-junit5-mockk:2.1.0")
@QuarkusTest
class FooTest {

    @InjectMock(relaxUnitFun = true)
    lateinit var bar: Bar

    @Test
    fun `Test access Bar`() {
        runTest {
            bar.foo()

            coVerify(exactly = 1) { bar.foo() }
        }
    }
}

@ApplicationScoped
class Bar {
    suspend fun foo() {
        delay(1000L)
        println("foo")
    }
}

@glefloch
Copy link
Member

@marvedly it is still an issue ? do you have more info ?

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

3 participants