After moving some previously working test code to ...
# multiplatform
j
After moving some previously working test code to its own
testing-support
module, I'm getting an error:
Unresolved reference: BeforeTest
for
kotlin.test.BeforeTest
during the
:testing-support:compileKotlinJvm
task. I've added
api(kotlin("test"))
to
:testing-support:commonMain
dependencies. The code works for macOS and iOS, but not JVM or Android targets. The IDE doesn't show an error, just during the compile task. Any idea why this doesn't work?
e
you need to choose a jvm implementation among kotlin-test-junit kotlin-test-junit5 kotlin-test-testng
j
Ah, that's right, thanks! I tried adding
junit
itself, but not the
kotlin-test
implementation. This must default to something in the
jvmTest
source set somehow, as I forgot it there before moving to its own module. It's working now after adding
api(kotlin("test-junit"))
.
e
it defaults to junit4 tests but that only works in the test source set, which means your separate module needs to handle it https://kotlinlang.org/docs/gradle-configure-project.html#set-dependencies-on-test-libraries
j
That makes sense, thanks.