io.mockk.MockKException: Bad recording sequence. Please finalize every { ... } block with returns/answers/just Runs
See original GitHub issue- MockK version: 1.8.13
- OS: Android
- Kotlin version: 1.3.10
- JDK version: 1.8
- JUnit version: 5
- Type of test: unit test OR android instrumented test
Stack trace
io.mockk.MockKException: Bad recording sequence. Please finalize every { ... } block with returns/answers/just Runs
class NoPermissionsPresenterTest : RxSpek({
val view = mockk<NoPermissionsContract.View> {
every { onVisibilityChangeObservable } returns Observable.just(true)
}
val navigator = mockk<NoPermissionsContract.Navigator> {
every { back() } returns Unit
}
val rxPermissions = mockk<RxPermissions> {
every { isGranted(any()) } returns true
}
val presenter by memoized(CachingMode.GROUP) {
NoPermissionsPresenter(
rxPermissions = rxPermissions,
navigator = navigator
)
}
describe("NoPermissionsPresenter tests") {
describe("view observables") {
beforeGroup {
presenter.attachView(view)
}
on("visibility change to true") {
view.onVisibilityChangeObservable.test()
it("check permissions") {
verify { rxPermissions.isGranted("") }
}
it("navigates back") {
verify { navigator.back() }
}
}
}
}
})
Issue Analytics
- State:
- Created 5 years ago
- Comments:5
Top Results From Across the Web
io.mockk.impl.recording.states.CallRecordingState.kt Maven ...
Please finalize every { ... } block with returns/answers/just Runs") } else { throw MockKException("Bad recording sequence. State: ${state::class.
Read more >Yes clear is suggested if you want to return back default be
RecordedCall(retValue=<error "io.mockk.MockKException: Bad recording sequence. Please finalize every { ... } block with returns/answers/just Runs">, ...
Read more >mockk-io/Lobby - Gitter
What's this error: io.mockk.MockKException: Bad recording sequence. State: StubbingState Just refresh the project, then some passing tests become failed xD.
Read more >How do you Mockk a Kotlin top level function? - Stack Overflow
Could the problem be that the top level function I'm trying to mock has a varargs parameter, but I'm doing every { sayHello(any(),...
Read more >Many tests suddenly fail with Spek 2.0.13 - Giters
Thanks for the report @svenjacobs. Are you able to provide a reproducer? My guess is that mockk doesn't play well with coroutines.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Just in case someone stumbles on this, in my case it was having trouble with the answer being an expression/function.
But this worked:
Hey, can I ask what was the problem?