I currently have: ```// In main module fun interfa...
# codereview
d
I currently have:
Copy code
// In main module
fun interface UseCase<in Request : Any, out Response> {
    suspend operator fun invoke(request: Request): Response?
}

fun interface SomeUseCase : UseCase<SomeRequest, SomeResponse>

// In test module
data class UseCaseSpy2<Request : Any, Response>(
    var response: Response = error("Must specify response."),
) {
    var request: Request? = null
        private set

    operator fun invoke(request: Request): Response {
        this.request = request

        return response
    }
}

// When wanting to create a spy for SomeUseCase in a unit test (to assert on requests to it or fake results from it...
val someUseCaseSpy = UseCaseSpy2<SomeRequest, SomeResponse>(Response(...))
val useCaseUsingSomeUseCase = SomeUseCase2({ someUseCaseSpy(it) })
I would like to use
SomeUseCase
as the type param in
UseCaseSpy2
instead of having to specify the request/response type... is there a way to do this? Or maybe there's a better way to provide the spy as a dependency to
useCaseUsingSomeUseCase
?