Cast exception when mocking kotlin lambda callbacks in Mockk
问题 I am having some trouble mocking callback functions with Mockk. I am trying to mock a task success listener that is called like this: collection .add(Item()) .addOnSuccessListener { update(collection.document(it.id)) } Where the java signature for the callback would look like this: public interface OnSuccessListener<T> { void onSuccess(T var1); } and the signature for addOnSuccessListener looks like this public abstract Task<DocumentReference> addOnSuccessListener(@NonNull OnSuccessListener