Closed okycelt closed 8 months ago
It's also reproducible in core/koin-test-junit4/src/test/kotlin/org/koin/test/CheckModulesTest.kt
. If you add a boolean param to Simple.ComponentB
the following test fails.
class Simple {
class ComponentB(val a: ComponentA, val b: Boolean)
}
@Test
fun `check module - dependency and param in one class`() {
val modules = module {
factory { p -> Simple.ComponentB(get(), p.get()) }
}
koinApplication {
modules(modules)
checkModules {
withInstance<Simple.ComponentA>()
withParameter<Simple.ComponentB> { true }
}
}
}
@arnaudgiuliani, would you mind taking a look?
yep 👍
It's a current limitation of checkModules
. You can't mix withInstance
and withParameter
for now. The current design is done to either provider value or dependency.
I would suggest looking more at Module.verify()
API
checkModules
is too complex to cover easily the configuration check. This will be deprecated in 3.6
Take a look at:
val modules = module {
factory { p -> Simple.MyComplexBool(get(), p.get()) }
}
modules.verify(extraTypes = listOf(Simple.ComponentA::class, Boolean::class))
Let open a new message thread if needed
Describe the bug I have three classes, two of which are declared in a module. In test, I provide the third class mock using
withInstance<Outsider>()
. But for some reason,checkModules()
throwsNoBeanDefFoundException: No definition found for type 'com.test.di.Outsider'. Check your Modules configuration and add missing type and/or qualifier!
. It seems to be related to the factory forFirst
having a parameter. If I remove that parameter,checkModules()
doesn't find any problems. Am I doing something wrong or is this a bug?To Reproduce Just run the attached test.
Expected behavior
checkModules()
shouldn't find any problems.Koin module and version:
koin-android
,koin-test-junit4
(koin-bom:3.5.0
)Snippet or Sample project to help reproduce