Pavel S
06/23/2023, 4:42 PMandroidTest
(instrumented) sourceset in common module?Jeff Lockhart
06/23/2023, 4:52 PMPavel S
06/23/2023, 4:58 PMtest
sourceset which I moved to commonTest
and it worked, and instrumented tests in androidTest
sourceset which I’m not sure where to move and how to run nowJeff Lockhart
06/23/2023, 5:00 PMPavel S
06/23/2023, 5:01 PMJeff Lockhart
06/23/2023, 5:03 PMandroidTest
currently, do they access Android-specific APIs like Context
? Or after migrating the code they test to KMP, is the code all in common? This will determine if the tests need to run as Android instrumented tests, or can just be added to your common tests as well.Jeff Lockhart
06/23/2023, 5:03 PMandroidUnitTest
, which equates to the Android test
source set, and androidInstrumentedTest
, which equates to the Android androidTest
source set (note this changed as of Kotlin 1.8.0).Pavel S
06/23/2023, 5:05 PMcommonTest
, can’t it?Jeff Lockhart
06/23/2023, 5:06 PMcommonTest
source set as well, possibly in a different package than the unit tests, if that makes sense.Jeff Lockhart
06/23/2023, 5:09 PMandroidUnitTest
source set is wired to the commonTest
source set tree. The androidInstrumentedTest
source set is not connected at all though, so it won't run common tests. You can change this, depending on your needs with a new API as of Kotlin 1.9.0.
If you have code that is Android-specific in your androidMain
source set that needs testing that can't use pure Kotlin common APIs, this is where you'd want to use `androidInstrumentedTest`s to run those tests on an Android device or emulator.Pavel S
06/23/2023, 5:14 PMcommonTest
. But I’ve tried to use androidInstrumentedTest
sourceset, but for some reason they are not executed when run with gradle and IDE shows this image when trying to launch it thereJeff Lockhart
06/23/2023, 5:24 PM./gradlew connectedAndroidTest
Run specific test class:
./gradlew connectedAndroidTest --tests *.ClassName
Run specific test method:
./gradlew connectedAndroidTest --tests *.ClassName.methodName
These test filters work with any of the platform-specific test tasks.Pavel S
06/23/2023, 5:26 PMconnectedAndroidTest
Jeff Lockhart
06/23/2023, 5:32 PM