Good evening. Sadly, i'm not good at testing and I...
# mockk
d
Good evening. Sadly, i'm not good at testing and I need some help. I'm trying to use mockk to mock my Retrofit API response. I?m trying to do as follow:
Copy code
Response.success(mockedResponseList)
Here's the code complete:
Copy code
coEvery { restApi.getAllBeersWithPagination(1, null).hint(Response::class) } coAnswers { Response.success(mockedResponseList)}
But it always returns:
java.lang.ClassCastException: java.lang.Object cannot be cast to retrofit2.Response
Someone can help me, please? Thanks
m
what does your
getAllBeersWithPagination
return?
i think you can just
Copy code
coEvery {
    restApi.getAllBeersWithPagination(1, null)
} returns Response.success(mockedResponseList)
btw
d
Hi, thanks for thw answer. I did what you said but unfortunatly the result was the same...
Anyway, the method returns a
Response<List<BeersListDTOItem>>