We have a KMM library where we exposing repository objects to our native apps (iOS/Android) and we're injecting these repository objects into our viewmodels within the native apps. What is considered best practice for defining these objects that are injected in the client apps so they can be mocked in the clients' unit tests. My first thought is to define them as interfaces and have a separate implementation that's called from the native DI code to return the actual KMM implementation obj for the given interface , so the native viewmodel would only reference the interface which would allow us to mock this in our unit tests. Just wanted to check if there is another best practice approach for declaring these shared classes that need to be mocked in client's unit tests
Example Of Our Current KMM Repo Class:
class TestRepository constructor(private val testApi: TestApi) {
fun getTestObj(): TestObj?{
val apiResponse = testApi.getTestObj()
return apiResponse.toModel()
}
}
Current Native VM Referencing Actual Repository Obj, But Needs To Be Mocked In Client's Unit Tests
class TestClientVM (kmmTestRepo: TestRepository){
....
}