Hey folks! I'm observing strange behaviour when ru...
# multiplatform
g
Hey folks! I'm observing strange behaviour when running
./gradlew connectedAndroidTest
where my shared module unit tests inside
src/commonTest/kotlin
also run as part of the Android instrumented tests. Anyone experienced this before? 🤔 More details in 🧵
1
I have a multi-module KMM setup and I have put a unit test inside
shared/src/commonTest/kotlin
and a few android instrumented tests which are under
app/src/androidTest
of the Android app. If I run
./gradlew test
only the unit tests run which is correct.
m
I've experienced the same thing. From my understanding
commonTest
is added to all the test source sets including the instrumented tests. I created a new module for my instrumented tests but that really wasn't the best solution. Probably would have been better to remove
commonTest/kotlin
from the android test source set.
g
Hey, thanks for the quick reply! 🙏
commonTest
 is added to all the test source sets including the instrumented tests
interesting, is there some reading I could look into related to this? Sounds like I might have missed it
I created a new module for my instrumented tests
I kind of have multiple feature modules on Android each with their own instrumented tests so I think removing 
commonTest/kotlin
 from the android test source set could be the way to go
g
brilliant, thank you! I'll post an update once I give this a try
g
I've been playing with this for the past 2 days and I felt I should post an update in case anyone else sees this. As it turns out my original issue wasn't related to
commonTest
running as part of the instrumentation tests - apparently it's meant to since it's part of the common KMM code. Rather, my issue was that the
connectedAndroidTest
was actually throwing a silent exception related to a missing
testInstrumentationRunner
on the KMM side. As soon as I added:
Copy code
android {
  defaultConfig {
    testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
  }
}
and
Copy code
val androidAndroidTest by getting {
  dependencies {
               implementation("androidx.test:runner:1.4.0")
            }
        }
commonTest
started to run with no exceptions during
connectedAndroidTest
🎉