Open
Description
Description
Requesting an unregistered object results in a runtime exception and there is no way to validate the dependency graph.
API example - Koin, a Service Locator for Kotlin
- https://insert-koin.io/docs/reference/koin-test/checkmodules/
- https://github.com/InsertKoinIO/koin/blob/main/core/koin-test/src/commonMain/kotlin/org/koin/test/check/CheckModules.kt#L96
I haven't investigated the get_it
implementation extensively enough, but here's an estimation of tasks involved:
- Add/Enforce a module structure, where you can retrieve all the bean definitions, for ex.
Module.getDefinitions()
- Provide mocked/fake beans for the definitions
- Try getting the beans. If a definition isn't provided fail the test
There's also an area I'm not sure how to avoid. The last layer, for ex. ViewModel
might not be defined in the configuration, so the test will result in a false-positive. Potential solution: go through all files instead of Module.getDefinitions()
and mimic getIt<XY>()
Metadata
Metadata
Assignees
Labels
No labels