How can I mock `androidContext` with `KoTest`/ usi...
# koin
l
How can I mock
androidContext
with `KoTest`/ using `checkKoinModules`:
Copy code
internal class DependencyGraphTest : KoinTest, WordSpec() {
    init {
        "Koin" should {
            "inject my components" {
                checkKoinModules(moduleGroupA + moduleGroupB + module {
                    // mock android context ??
                })
            }
        }
    }
}
Solved
Copy code
internal class DependencyGraphTest : KoinTest, WordSpec() {
    init {
        "Koin" should {
            "inject components" {
                val context: Context = mockk()
                val adapter: BluetoothAdapter = mockk(relaxed = true)

                every {
                    (context.getSystemService(Context.BLUETOOTH_SERVICE) as BluetoothManager)
                        .adapter
                } returns adapter

                checkKoinModules {
                    androidContext(context)
                    modules(bluetoothModule)
                    modules(appModule)
                    modules(libraryModule)
                }
            }
        }
    }
}
181 Views