Am I correct that kotest doesn’t support coroutine...
# kotest
i
Am I correct that kotest doesn’t support coroutines
-native-mt
? I’m getting this in my gradle dependencies:
Copy code
+--- org.jetbrains.kotlinx:kotlinx-coroutines-core:{strictly 1.6.0-native-mt} FAILED
s
What do you mean support it.
i
Well my dependencies are confusing me at the moment. The list of runtime dependencies seems to force resolve coroutines core to
1.6.0
and that appears to mess up many of the libraries that depend on
1.6.0-native-mt
. However, as far as I can tell the compile dependencies resolve as I would expect them to to native-mt. So
releaseUnitTestRuntimeClasspath
seems to resolve to 1.6.0 while
releaseUnitTestCompileClasspath
resolves to 1.6.0-native-mt. Any idea why it would differ?
s
No that doesn't make much sense to me either
i
Does kotest require a JVM target? I see that the sample projects always seem to have a JVM target. By default KMM doesn’t add a JVM target, although tests that run under commonTest execute on the JVM.
s
nope
you can JS only for instance
or native only
i
I’ve configured kotest in the commonTest sourceSet:
Copy code
val commonTest by getting {
            dependencies {
                implementation(kotlin("test"))
                implementation(kotlin("test-common"))
                implementation(kotlin("test-annotations-common"))
                implementation("org.jetbrains.kotlinx:kotlinx-coroutines-test:$coroutines_version")
                implementation("io.kotest:kotest-assertions-core:$kotest_version")
                implementation("io.kotest:kotest-framework-engine:$kotest_version")
                implementation("io.kotest:kotest-framework-datatest:$kotest_version")
                implementation("io.kotest:kotest-assertions-core:$kotest_version")
            }
        }
s
looks fine
you're mixing kotlin test and kotest though, any reason ?
i
All my current tests were built using kotlin test. I was trying to add kotest with the plan to eventually phase out/replace existing tests.
s
ah ok
I don't know what native-mt does to be honest, but you could try adding the rest of the kotlin coroutine deps that kotest uses, and using the version you want
Copy code
const val debug = "org.jetbrains.kotlinx:kotlinx-coroutines-debug:_"
const val coreCommon = "org.jetbrains.kotlinx:kotlinx-coroutines-core:_"
const val coreJvm = "org.jetbrains.kotlinx:kotlinx-coroutines-core-jvm:_"
const val coreNative = "org.jetbrains.kotlinx:kotlinx-coroutines-core-native:_"
const val jdk8 = "org.jetbrains.kotlinx:kotlinx-coroutines-jdk8:_"
const val test = "org.jetbrains.kotlinx:kotlinx-coroutines-test:_"
you won't need jdk8 or jvm
i
I’ve already got:
Copy code
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutines_version") {
                    version { strictly(coroutines_version) }
                }
Under commonMain
s
yeah that's just core though
oh I see
I guess the other one is debug
i
My runtime dependency failures appear to be on core and not debug 🤨
s
wouldn't hurt to have them all on the same though
i
Ahhhh….just tried it out on a brand new project and it fails there too…
Let me see if I can push it to github and you can see it
If you clone that repo and run
./gradlew :shared:dependencies
you’ll see what I mean
@sam Thank you so much for your help with this 😀
s
* What went wrong: Could not determine the dependencies of task 'androidApptestDebugUnitTest'.
SDK location not found. Define location with an ANDROID_SDK_ROOT environment variable or by setting the sdk.dir path in your project's local properties file at '/home/sam/development/workspace/KotestNativeMt/local.properties'.
i
Ahhh…yes I have a local.properties with:
sdk.dir=/Users/steve/Library/Android/sdk
s
can you fix the repo and I'll repull
it'll need to auto install android
I don't have it locally
i
KMM generates it for you but it needs to be set by each individual user
s
ok
I'm also on linux so the ios stuff won't do much
So what should I set my sdk.dir to be ? and where should I put it
i
I think I just installed Android Studio and it placed it for me automagically.
Not sure on linux where that is supposed to be.
s
ok, then I guess can you make this issue without android ?
i
I would think so
Let me see….
s
might help if it's just a boring native build wihtout android or ios
i
Well that’s interesting…when I remove android the problem goes away….maybe there is an android configuration I need?
s
oh there's lots of issues with androids 'unique' (ab)use of gradle
I'm not an android user myself but I've seen issues before with this runtime and compile time classpath thing. If you delve through the kotest channel history, you might find something useful.
Or ask a specific question at the top level around android configs and wait for someone to see next week
i
working on it… doesn’t seem to like this from the docs:
Copy code
android.testOptions {
    unitTests.all {
        useJUnitPlatform()
    }
}
@sam I got it working by switching to 1.6.0 without the native-mt. Unfortunately some libraries still require it but for me they seem to be working with the switch so fingers crossed. I think 1.7 is deprecating native-mt. But it might make sense to update kotest docs around coroutines.