SimpleTestingServiceLocator
A SimpleServiceLocator subclass designed specifically for use in tests.
This locator provides two key features to simplify testing:
Automatic Mocking: If a service is requested that has not been explicitly registered, this locator will automatically create and return a mock instance for it by calling the abstract createMock function.
Re-registration: Unlike the production locator, this class allows a key to be registered multiple times, overwriting the previous registration. This is useful for setting up different fakes or mocks for different test cases within the same test suite.
Parameters
S
The type of the scope identifier.
scope
The specific scope instance for this locator, which should be a testing-specific scope.
Functions
Link copied to clipboard
inline fun <T : Any> getOrProvide(noinline allowedScopes: (S) -> Boolean, threadSafetyMode: LazyThreadSafetyMode, noinline provider: (S) -> T): T