koin
koin copied to clipboard
Problems when add Koin Test
Hi I am usin Koin en JVM app, without problem, but I would like to use Koin for testing In my Gradle val kotlinVersion: String = "1.7.10" val koinVersion: String = "3.2.0"
kotlin("jvm") version "1.7.10"
implementation("io.insert-koin:koin-core:$koinVersion") testImplementation(kotlin("test")) testImplementation("io.insert-koin:koin-test:$koinVersion")
But when I try to run the test
Execution failed for task ':compileTestKotlin'.
Error while evaluating property 'filteredArgumentsMap' of task ':compileTestKotlin' Could not resolve all files for configuration ':testCompileClasspath'. > Could not resolve org.jetbrains.kotlin:kotlin-test-junit5:1.7.10. Required by: project : > org.jetbrains.kotlin:kotlin-test:1.7.10 > Module 'org.jetbrains.kotlin:kotlin-test-junit5' has been rejected: Cannot select module with conflict on capability 'org.jetbrains.kotlin:kotlin-test-framework-impl:1.7.10' also provided by [org.jetbrains.kotlin:kotlin-test-junit:1.6.21(junitApi)] > Could not resolve org.jetbrains.kotlin:kotlin-test-junit:1.6.21. Required by: project : > io.insert-koin:koin-test:3.2.0 > io.insert-koin:koin-test-jvm:3.2.0 > Module 'org.jetbrains.kotlin:kotlin-test-junit' has been rejected: Cannot select module with conflict on capability 'org.jetbrains.kotlin:kotlin-test-framework-impl:1.6.21'
Same for me. Simply forcing gradle resolution did not work for me:
- https://docs.gradle.org/current/userguide/dependency_capability_conflict.html#sub:selecting-between-candidates
It looks like koin-test 3.2.0 absolutely pins down to kotlin-test-junit.1.6.21.
Do we really need to downgrade kotlin to 1.6.21 in order to use koin testing?
I ended up working around koin-test kind of re-implementing starting / stopping koin within ktor testApplication, cf.:
- https://ktor.io/docs/testing.html#configure-test-app
Same issue here.
next version of Koin will bring it for Kotlin 1.7.10
Koin 3.3 is updated to Kotlin 1.7.21
https://github.com/InsertKoinIO/koin/blob/core/3.3.0/gradle/versions.gradle#L7
💪💪💪👏👏👏👏👏