Anyone know how to make `androidTestImplementation...
# multiplatform
c
Anyone know how to make
androidTestImplementation
compile in a compose multiplatform project?
j
the instrumented tests are their own source set
so you don't add it to androidMain, you add it to androidInstrumentedTest or something as an
implementation
dependency
🤔 1
c
seems like this works. need to work through some other compilation issues before a concrete yes/no. but that works. thanks jake
Copy code
androidNativeTest.dependencies {
    implementation("androidx.compose.ui:ui-test-junit4")
}
j
yeah i believe "androidNative" is the aggregate source set for the android native targets that you probably aren't using
j
It is
androidInstrumentedTest
that you want. Note that by default, this source set is not connected to the
commonTest
source set tree, so it won't run common code. If you want it to be, then you can specify the source set tree like this:
Copy code
kotlin {
    @OptIn(ExperimentalKotlinGradlePluginApi::class)
    androidTarget {
        instrumentedTestVariant.sourceSetTree.set(KotlinSourceSetTree.test)
        unitTestVariant.sourceSetTree.set(KotlinSourceSetTree.unitTest)
    }
}
This connects the
androidInstrumentedTest
source set to the
commonTest
tree, and disconnects the
androidUnitTest
source set from it, assuming you want to run your common tests as instrumented tests and not unit tests.
👍 1
today i learned 1
c
Going to go out on a whim and ask here even though it's arguably a different question. I have free and paid build variants. in android {} i have
Copy code
productFlavors {
  create("free") {
    dimension = "stage"
    applicationIdSuffix = ".free"
  }

  create("paid") { dimension = "stage" }
}
then in kotlin {} i have
Copy code
sourceSets {
    sourceSets.invokeWhenCreated("androidFree") {
    }
    sourceSets.invokeWhenCreated("androidPaid") {
    }
I updated my dirs from /free and /paid to androidFree and androidPaid. does that all seem correct?