:test_tube: UNIT TESTS: I want to use: - Kotlin T...
# multiplatform
m
🧪 UNIT TESTS: I want to use: • Kotlin Test (
org.jetbrains.kotlin:kotlin-test
) • JUnit (
org.jetbrains.kotlin:kotlin-test-junit
) • MockK (
io.mockk:mockk-common
) in my AndroidTest source set. Can someone tell me what is the right
sourceSet
for this? I tried
androidMain
and
androidNativeTest
, but if i add the dependencies there, they are not available in my
src/androidTest/kotlin
directory. How would the right setup be?
j
You should be using either
src/androidUnitTest/
or
src/androidInstrumentedTest/
directories now. See https://kotlinlang.org/docs/multiplatform-android-layout.html
The Gradle configurations into which dependencies can be placed for those source sets match their names with "Implementation" appended
You can validate your dependencies are going the right place with the
dependencies
task and looking for the matching configuration names
Or, you know, by just trying to use them
m
Thx @jw! I did not know I need to get
androidUnitTest
source set differently than
commonMain
,
iosMain
or
androidMain
. Had to add `by getting`:
Copy code
val androidUnitTest by getting
androidUnitTest.dependencies {
    implementation(libs.kotlin.test)
    implementation(libs.kotlin.test.junit)
    implementation(libs.mockk)
}
Now it works. Thx!
m
if there is a source set with
Main
there is normally another one with
Test
.
commonMain
,
commonTest
,
iosMain
,
iosTest
. Android is special, since it has two source sets for tests.