Hey there, after migrating my CMP project to AGP 9...
# multiplatform
m
Hey there, after migrating my CMP project to AGP 9 I start to see this warning:
Copy code
Unused Kotlin Source Sets
The Kotlin source set androidUnitTest was configured but not added to any Kotlin compilation.
Solution: You can add a source set to a target's compilation by connecting it with the compilation's default source set using 'dependsOn'.
See <https://kotl.in/connecting-source-sets>
I tried to let androidUnitTest depends on commonTest but then I start to see another warning saying i am breaking the hierarchy
m
HI, if You're following KMP preferred structure, You should migrate unit tests (
androidUnitTest
) to host tests (
androidHostTest
) and instrumented tests (
androidInstrumentedTest
) to device tests (
androidDeviceTest
). If You have any dependencies for test source sets, You have to add them to proper source set (unit -> host, instrumented -> device), which You have to get by name. Link for developer.android.com guide: https://developer.android.com/kotlin/multiplatform/plugin#configure-tests Example configuration (Step 4. for dependencies configuration) https://developer.android.com/kotlin/multiplatform/plugin#apply
m
@Marcin Kiżewski but in this case
androidHostTest
and
androidDeviceTest
would be in shared module or in androidApp?
m
Those source sets are created by
android.kotlin.multiplatform.library
plugin, so if Your tests are in shared module then these apply to shared module. In androidApp module
androidUnitTest
and
androidInstrumentedTest
should still be available
👍 1
m
Thank you