so i have a fairly simple piece of code. Nothing t...
# kotest
v
so i have a fairly simple piece of code. Nothing to crazy...
Copy code
declareMock<Database>(named(InjectableModules.SONG_DATABASE_NAME)) {
         justRun { update(any(), any()) }
         justRun { add(any()) }

    }
YET IT STILL BREAKS Caused by: java.lang.IllegalStateException: Missing MockProvider. Please use MockProvider.register() to register a new mock provider WHY is it breaking.
s
it looks like koin and mockk’s problem isn’t it? https://github.com/InsertKoinIO/koin/issues/841#issuecomment-653407887
v
yes turns out that when you do the registermock you have to do it FIRST or in a beforeeach..
p
with
mockery
i can test with kointest in commonTest with this syntax :
MockProvider.register {
mock<Database>
}
And after I can use
declareMock<Database> {
}
But in kotlin multiplatform not equivalent for that :
@get:Rule
_val_ mockProvider = MockProviderRule.create { clazz ->
// Your way to build a Mock here
mockkClass(clazz)
}