I have read it here. It is close to my problem and I need more guidance on this part.
Given,
class Journey{
fun start(){
Service.getInstance().getProductInfo(activity,object: Service.Callback<Product>{
override fun onSuccess(data: Product) {
showProductInfo(activity, data, customer)
}
override fun onError(e: Throwable) {
showError(e)
}
})
}
}
and I want to mock Service.getProductInfo and perform happy path and unhappy path handling, how do I do it with mockk?
Additional question, is there a way to exclude certain function like start above in jacoco? Sometimes some functions has not much meaning for unit test and excluding it in jacoco makes much more sense.
UPDATE:
I learnt from Gradle website that it does not currently support method exclusion.
Callback interface is below
interface Callback<T>{
fun onSuccess(data: T)
fun onError(e: Throwable)
}
I'm using retrofit for Service.