svenjacobs
02/08/2019, 12:01 PMcoEvery { view.showDeleteSectionDialog() } returns true
produces
Bad recording sequence. State: AnsweringState
but
with(view) {
coEvery { showDeleteSectionDialog() } returns true
}
does not?verify
functions onlyoleksiyp
02/08/2019, 3:22 PMsvenjacobs
02/08/2019, 4:02 PMoleksiyp
02/08/2019, 4:06 PMsvenjacobs
02/08/2019, 4:06 PMoleksiyp
02/08/2019, 4:06 PMsvenjacobs
02/11/2019, 6:50 AMoleksiyp
02/11/2019, 9:13 PMsvenjacobs
02/12/2019, 11:40 AMoleksiyp
02/12/2019, 11:41 AMsvenjacobs
02/12/2019, 11:42 AMval mock by memoized {
mockk<Cache<Entry>> {
coEvery { tryGet("uuid") } returns entry1
}
}
Now when I try to specify additional behaviour in a test with coEvery { mock... }
I get this error whereas with(mock) { coEvery { ... } }
works. When I remove memoized
both variants works. It seems to be related to the memoized
delegate.oleksiyp
02/14/2019, 7:44 AMmock
variable in the scope it is being initialized. Just add more behaviours without itsvenjacobs
02/14/2019, 7:59 AMclass Test : Spek(
{
val mock by memoized {
mockk<MyClass> {
coEvery { doSomething() } returns SOMETHING
}
}
it("should do something") {
coEvery { mock.doSomethingElse() } returns SOMETHING_ELSE
// further test...
}
it("should do something else") {
coEvery { mock.doSomethingElse() } returns null
// further test...
}
})
oleksiyp
02/14/2019, 9:10 AMevery
. Nothing you can do about itsvenjacobs
02/14/2019, 10:52 AMwith(memoizedMock) { coEvery { ... } }
is different than coEvery { memoizedMock... }
. Shouldn't the property be initialized when the property is accessed?oleksiyp
02/14/2019, 11:02 AMsvenjacobs
02/14/2019, 11:04 AMcoEvery { mock.something() }
assumes that mock
has been initialized before the call of coEvery
?oleksiyp
02/14/2019, 12:03 PM