I have a project with multiple modules. One of the modules is kotlin multiplatform. I'm trying to add unit tests for it using Kotest 4.1.1. This release is published in repository mavenCentral(), and I can use this release just fine in a module that is using the java library plugin. But every attempt to sync when using Kotest 4.1.1 in the multiplatform module fails:
Could not resolve io.kotest:kotest-runner-junit5-jvm:4.1.1.
I can't see why this is happening. This error is definitely specific to the module using the kotlin multiplatform plugin, as a different module in the same project using the regular kotlin jvm plugin and the same release of kotest can sync just fine. So gradle is definitely capable of finding the release in the defined repositories and using kotest 4.1.1.
As a result (no surprise), the kotest stuff is not on the test classpath for commonTest in the multiplatform module, so the unit test classes cannot import the io.kotest.xxx packages.
I was hoping to use kotest in JVM-run unit tests (using junit5) to test the multiplatform code. But this is my first attempt at doing multiplatform, so everything is suspect :-)
The snippet below is the sourceSets code from the multiplatform module's build.gradle.kts. If the commented part is left as-is, gradle syncs fine but source in commonTest of course doesn't see kotest. If the comments are removed, the error occurs
sourceSets {
commonMain {
dependencies {
implementation(kotlin("stdlib-common"))
}
}
/*
commonTest {
dependencies {
implementation(Kotest.framework)
}
}
*/
}
Here's the value of the Kotest.framework val, used in both modules:
object Kotest {
const val version = "4.1.1"
const val framework = "io.kotest:kotest-runner-junit5-jvm:$version"
const val assertions = "io.kotest:kotest-assertions-core-jvm:$version"
const val propertyTest = "io.kotest:kotest-property-jvm:$version"
}
Has anyone gotten kotest 4.1.1 to work when using the kotlin multiplatform plugin in Android Studio? Any ideas about how to diagnose this further would be appreciated. Thanks in advance...
Config: Android studio 4.0 Gradle 6.5.1 Kotlin 1.3.72
io.kotest:kotest-runner-junit5
dependency instead ofio.kotest:kotest-runner-junit5-jvm
? – Max