Hello everyone, This is my 1st time with kotlin mu...
# multiplatform
m
Hello everyone, This is my 1st time with kotlin multiplatform. I’m trying to write and run unit tests for the android target. However I’d like those unit tests to be jvm only. For example, everytime, I try to run my tests, I have an emulator that is started. I’d like to avoid that and run them only in jvm mode. Is it possible?
k
yes. point your Android
test
source set at your KMM
androidTest
source set, rather than
androidTest
->
androidTest
m
@Kris Wong That’s great. Im not sure how to do that though. I tried to set
sourceSets["test"].setRoot("src/androidTest/java")
in my
android
block configuration but didnt work. So I guess I’m doing something wrong.
I also tried the following but didnt work either
sourceSets["test"].java.srcDir(file("src/androidTest/java"))
m
Thank you. I’m looking at it 🙂
Ok I followed the guide but it still launches an emulator. I must be missing something. Here is android block
Copy code
android {
    compileSdkVersion(30)

    sourceSets {
        getByName("main") {
            manifest.srcFile("src/androidMain/AndroidManifest.xml")
        }
        
        getByName("test") {
            java.srcDirs("src/androidTest/java")
            res.srcDirs("src/androidTest/res")
        }
    }
    testOptions.unitTests.isIncludeAndroidResources = true

    defaultConfig {
        minSdkVersion(24)
        targetSdkVersion(30)
    }


    compileOptions {
        sourceCompatibility = JavaVersion.VERSION_1_8
        targetCompatibility = JavaVersion.VERSION_1_8
    }
}
It ended up working at some point ¯\_(ツ)_/¯ Thanks for your help 🙂
🍻 1