Closed vdshb closed 1 year ago
Version 1.9.0
published with the fix.
I am still getting this issue with 0.11.0
I defined usesHelper = false
and useJUnitPlatform()
Execution failed for task ':kspTestKotlinJvm'.
> Error while evaluating property 'filteredArgumentsMap' of task ':kspTestKotlinJvm'
> Could not resolve all files for configuration ':jvmTestCompileClasspath'.
> Could not resolve org.jetbrains.kotlin:kotlin-test-junit:1.7.22.
Required by:
project :
> 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.7.22' also provided by [org.jetbrains.kotlin:kotlin-test-junit5:1.7.22(junit5Api), org.jetbrains.kotlin:kotlin-test-junit5:1.7.21(junit5Api)]
> Could not resolve org.jetbrains.kotlin:kotlin-test-junit5:1.7.22.
Required by:
project : > org.jetbrains.kotlin:kotlin-test:1.7.22
> 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.21' also provided by [org.jetbrains.kotlin:kotlin-test-junit:1.7.22(junitApi)]
You need to use:
mockmp {
usesHelper = true
}
kotlin {
sourceSets {
val commonTest by getting {
dependencies {
implementation(kotlin("test"))
implementation("org.kodein.mock:mockmp-test-helper:0.11.0")
}
}
}
}
I'll reopen this issue because I forgot to document this. Furthermore, the Gradle plugin should apply the correct Junit helper.
The 1.12.0 Gradle plugin applies the correct dependency according to your test framework. Thanks for the report !
org.kodein.mock:mockmp-test-helper-jvm contains org.jetbrains.kotlin:kotlin-test-junit as a dependency.
org.jetbrains.kotlin:kotlin-test-junit5 and org.jetbrains.kotlin:kotlin-test-junit conflict with each other.
When project configured to use junit5 and we add mocKMP helper to it then we'll get compile time exception on running jvmTest:
Reproducer:
build.gradle.kts:
src/commonTest/kotlin/com/example/ExampleTest.kt:
Switching to Junit4 (
useJUnitPlatform()' -> 'useJUnit()
) or removing mocKMP helper (usesHelper = true
->usesHelper = false
) make test runnable again.