Looks like adding `kotlin-test` as a `commonMain` ...
# test
m
Looks like adding
kotlin-test
as a
commonMain
dependency makes
compileTestKotlinJvm
fail with
Unresolved reference 'kotlin.test.Test'
? Is that expected?
e
needs
kotlin-test-junit5
or one of the other variants to `avtual`ize the `expect`ed types on JVM
🎯 1
I think KGP sets that up to happen automatically if it's in
commonTest
, maybe it doesn't work if you put it in
commonMain
👍 1
m
That was it, thanks!
Interestingly, this doesn’t work
Copy code
getByName("commonMain") {
      dependencies {
        implementation("org.jetbrains.kotlin:kotlin-test")
      }
    }
    getByName("commonTest") {
      dependencies {
        implementation("org.jetbrains.kotlin:kotlin-test")
      }
    }
But this does
Copy code
getByName("commonMain") {
      dependencies {
        implementation("org.jetbrains.kotlin:kotlin-test")
      }
    }
    getByName("commonTest") {
      dependencies {
        implementation("org.jetbrains.kotlin:kotlin-test-junit5")
      }
    }
e
well the usual thing would be
Copy code
commonTest {
  dependencies {
    implementation(kotlin("test"))
  }
}
jvmTest {
  dependencies {
    implementation(kotlin("test-junit5"))
  }
}
and I guess you're doing it in
commonMain
for some reason instead of
commonTest
, but then I'd put the JVM dependency in
jvmMain
👍 1
m
I want to use
assertFoo
in
commonMain
because this is code that I want to publish and use from other tests. Ideally I would use test fixtures but haven’t been able to so far
My current understanding is that adding
kotlin-test
to
commonMain
triggers maybeAddTestDependencyCapability “earlier” (
testCapability
is null there) and therefore prevents the automatic adding of
kotlin-test-junit5
Anyways, it’s all working now, thanks!