koin icon indicating copy to clipboard operation
koin copied to clipboard

Problems when add Koin Test

Open joseluisgs opened this issue 2 years ago • 4 comments

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'

joseluisgs avatar Jul 22 '22 16:07 joseluisgs

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?

mkoertgen avatar Aug 02 '22 09:08 mkoertgen

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

mkoertgen avatar Aug 02 '22 12:08 mkoertgen

Same issue here.

lsrom avatar Aug 05 '22 07:08 lsrom

next version of Koin will bring it for Kotlin 1.7.10

arnaudgiuliani avatar Aug 26 '22 15:08 arnaudgiuliani

Koin 3.3 is updated to Kotlin 1.7.21

https://github.com/InsertKoinIO/koin/blob/core/3.3.0/gradle/versions.gradle#L7

arnaudgiuliani avatar Dec 13 '22 10:12 arnaudgiuliani

💪💪💪👏👏👏👏👏

joseluisgs avatar Dec 13 '22 15:12 joseluisgs