Jacob Hughes
02/01/2022, 11:32 AMkotlin.IllegalStateException: KoinApplication has not been started
. When I run the test individual the test passes as expected.
For context each of my test classes extends implements this abstract class:
abstract class KoinTest : KoinComponent {
@BeforeTest
fun beforeTest() {
println("Starting Koin")
startKoin {
printLogger(Level.ERROR)
modules(
module {
single { Log(testing = useMocks) }
},
)
}
}
@AfterTest
fun after() {
stopKoin()
}
}
From my build.gradle
dependencies {
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.6.10")
classpath("com.android.tools.build:gradle:7.0.4")
}
val commonTest by getting {
dependencies {
implementation(kotlin("test"))
implementation(kotlin("test-common"))
implementation(kotlin("test-annotations-common"))
implementation("io.kotest:kotest-assertions-core:5.0.1")
implementation("io.kotest:kotest-framework-engine:5.0.1")
implementation("app.cash.turbine:turbine:0.7.0")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.0-native-mt")
implementation("io.insert-koin:koin-core:3.1.5")
}
}
Has anyone come across any similar issues?Jacob Hughes
02/04/2022, 9:24 AM// is lazy evaluated
val myService : MyService by inject()
and then attempt to use an instance injected by Koin in the initialiser of that class it hasn't yet been injected by Koin. This effects iOS only.
Instead use:
// retrieve directly the instance
val myService : MyService = get()
This retrieves the dependency eager meaning it can be used immediatelyarnaud.giuliani
02/04/2022, 4:59 PM