mike.holler
10/07/2020, 8:13 PMkotlinx-coroutines-test
to help me with this, but unfortunately I ended up getting an error.
val commonMain by getting {
dependencies {
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.9")
implementation("io.ktor:ktor-client-core:1.4.0")
}
}
val commonTest by getting {
dependencies {
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-test:1.3.9")
implementation(kotlin("test-common"))
implementation(kotlin("test-annotations-common"))
}
}
Error:
Caused by: org.gradle.internal.resolve.ModuleVersionResolveException: Could not resolve org.jetbrains.kotlinx:kotlinx-coroutines-test:1.3.9.
Required by:
project :
Caused by: org.gradle.internal.component.NoMatchingConfigurationSelectionException: No matching variant of org.jetbrains.kotlinx:kotlinx-coroutines-test:1.3.9 was found. The consumer was configured to find a usage of 'kotlin-runtime' of a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'js', attribute 'org.jetbrains.kotlin.js.compiler' with value 'legacy' but:
- Variant 'apiElements' capability org.jetbrains.kotlinx:kotlinx-coroutines-test:1.3.9:
- Incompatible because this component declares an API of a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'jvm' and the consumer needed a usage of 'kotlin-runtime' of a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'js'
- Other compatible attribute:
- Doesn't say anything about org.jetbrains.kotlin.js.compiler (required 'legacy')
- Variant 'runtimeElements' capability org.jetbrains.kotlinx:kotlinx-coroutines-test:1.3.9 declares a runtime of a component:
- Incompatible because this component declares a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'jvm' and the consumer needed a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'js'
- Other compatible attribute:
- Doesn't say anything about org.jetbrains.kotlin.js.compiler (required 'legacy')
kotlinx-coroutines-test
line, I no longer get this error but of course then cannot test coroutines.Tijl
10/07/2020, 8:15 PMandroid*Test
or jvmTest
sourcesetsmike.holler
10/07/2020, 8:16 PMcommonTest
then?kotest
but I'd rather avoid bringing another test framework into this.Tijl
10/07/2020, 8:24 PMmike.holler
10/07/2020, 8:28 PMbut it’s not impossible to write tests without it.@Tijl this is what I'm interested in. I don't know how to get started with writing tests that are capable of being run in commonTest with coroutines. I'm having trouble finding resources.
Tijl
10/07/2020, 8:32 PMrunBlocking
to run your entire test (and any other scopes from there). if you need different behaviour for testing use the familiar injection patterns.mike.holler
10/07/2020, 8:34 PMrunBlocking
is not available in common
or js
, it's purely a JVM and native feature.Tijl
10/07/2020, 8:41 PMmike.holler
10/07/2020, 8:50 PMTijl
10/08/2020, 11:37 AM