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

cannt mock PackageInfo #1135

Open
lannyf77 opened this issue Aug 18, 2023 · 0 comments
Open

cannt mock PackageInfo #1135

lannyf77 opened this issue Aug 18, 2023 · 0 comments

Comments

@lannyf77
Copy link

Tryin to mock the android.content.pm.PackageInfo, and stub the versionName.

    @Test
    fun test_() {

        val pInfoMock = mockk<PackageInfo>()
        every { pInfoMock.versionName } returns "test_version". //<==got error
        // ......
    }

it got error:

Missing mocked calls inside every { ... } block: make sure the object inside the block is a mock
io.mockk.MockKException: Missing mocked calls inside every { ... } block: make sure the object inside the block is a mock
	at io.mockk.impl.recording.states.StubbingState.checkMissingCalls(StubbingState.kt:14)
	at io.mockk.impl.recording.states.StubbingState.recordingDone(StubbingState.kt:8)
	at io.mockk.impl.recording.CommonCallRecorder.done(CommonCallRecorder.kt:47)
	at io.mockk.impl.eval.RecordedBlockEvaluator.record(RecordedBlockEvaluator.kt:64)
	at io.mockk.impl.eval.EveryBlockEvaluator.every(EveryBlockEvaluator.kt:30)
	at io.mockk.MockKDsl.internalEvery(API.kt:94)
	at io.mockk.MockKKt.every(MockK.kt:143)

what does this mean?

Missing mocked calls inside every { ... } block: make sure the object inside the block is a mock
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