Mocking suspend function so that it rise an exception (Kotlin, unit testing, mockito)
I have a suspend function:
override suspend fun fetch(
userId: String,
userChannel: String,
deviceId: String,
): List {
val docSelector = ...
return db.getCollection().find(docSelector).toList()
}
I want to mock it in the test so that when it is called, an exception is thrown.
I did it this way:
this is the block of production code which calls the fetch() function and in which I want to jump to line (1) when running from the test...