У меня есть следующая функция, на основе которой я пытаюсь создать модульный тест:
Код: Выделить всё
@RequiresApi(Build.VERSION_CODES.TIRAMISU)
private suspend fun Geocoder.getFromLocationApi33(
latitude: Double,
longitude: Double
) = suspendCancellableCoroutine { continuation ->
this.getFromLocation(latitude, longitude, MAX_RESULTS) { addresses ->
continuation.resumeWith(Result.success(addresses.firstOrNull()))
}
}
Код: Выделить всё
val geocoder = mockk()
val addressSlot = slot Unit>()
coEvery {
geocoder.getFromLocation(0.0, 0.0, 1, capture(addressSlot))
}.answers {
addressSlot.captured.invoke(mutableListOf())
}
Не удалось сопоставить макет подпись для SignedCall(retValue=,
isRetValueMock=true, retType=class kotlin.Unit, self=Geocoder(#5),
method=getFromLocation(Double, Double, Int, GeocodeListener),
args=[0.0, 0.0, 1,
com.weatherxm.util.GeocoderCompatTest$1$2$2$3$1$1$$Lambda$314/0x000000010059eab8@73c3ceb5],
invoctionStr=Geocoder(#5).getFromLocation (0.0, 0.0, 1,
com.weatherxm.util.GeocoderCompatTest$1$2$2$3$1$1$$Lambda$314/0x000000010059eab8@73c3ceb5))
левые сопоставления: [slotCapture()]
Есть идеи, как решить эту проблему?
Подробнее здесь: https://stackoverflow.com/questions/790 ... nature-for