mockspresso-api / com.episode6.hackit.mockspresso / Mockspresso / getDependency

getDependency

abstract fun <T : Any!> getDependency(@NotNull key: DependencyKey<T>): T

Get a dependency (creating a new mock, if needed) from mockspresso. We purposefully don't annotate the return-type here NotNull because nulls are theoretically allowed dependencies (they just must be mapped explicitly). So kotlin users must assume nullability via platform-type.

Parameters

key - DependencyKey<T>: The dependency key to lookup or mock.

- Dependency type

Return
T: The dependency or a new mock if it is not present.