https://kotlinlang.org logo
#android
Title
# android
k

Kulwinder Singh

03/10/2020, 12:11 PM
for MockK, i'm getting
MockKException: no answer found for: MyClass(#1).sendMessage(okhttp3.RequestBody$2@4ed4bd33)
, actually RequestBody's properties are same just instance is different. that's why it did not matches parameters but if i add
any()
instead of requestbody it works. is there anything else i can use instead of
any()
here ?
Copy code
every {	myClass.sendMessage(MockRequest.createTestBody(value="text")) } answers { something }

....

class SomeObject(myClass:MyClass){
	fun doSomething(text: String): Flowable<Result<Boolean>> {
        val request = MockRequest.createTestBody(text)
		myClass.sendMessage(request)
	}
}
....
i have checked documentation of mockk but didn't found anything, that's why asked here:
m

Matt Thompson

03/10/2020, 12:53 PM
there’s a #mockk channel, but the issue might just be that whatever is returned by
createTestBody
doesn’t implement
equals
correctly. maybe return a data class if possible?
k

Kulwinder Singh

03/10/2020, 1:29 PM
createTestBody
returns
RequestBody
from okhttp @Matt Thompson
m

Matt Thompson

03/10/2020, 10:27 PM
yeah those will probably only be equal if they’re the same instance
5 Views