andylamax
03/01/2024, 1:00 AMrunComposeUiTest
can be written in commonMain, but when I ran those tests in android (./gradlew :testDebugUnitTest
or ./gradlew testReleaseUnitTest
), I am getting
Unresolved reference 'runComposeUiTest'
The same tests run fine on jvm target with (./gradlew :jvmTest
)
I did setup my dependencies in commonTest
as show below,
val commonTest by getting {
dependencies {
implementation(compose.uiTest)
}
}
What am I doing wrong? using compose version 1.6.0Ivan Matkov
03/01/2024, 12:36 PMAlexander Maryanovsky
03/01/2024, 12:37 PMandylamax
03/01/2024, 1:40 PM./gradlew testDebugUnitTest
only run on the machine (not the android phone or emulator), and I think it does, just can't seem to find those dependenciesAlexander Maryanovsky
03/01/2024, 1:41 PMAlexander Maryanovsky
03/01/2024, 1:41 PMAlexander Maryanovsky
03/01/2024, 1:41 PMAlexander Maryanovsky
03/01/2024, 1:42 PMandylamax
03/01/2024, 1:42 PMAlexander Maryanovsky
03/01/2024, 1:43 PMAlexander Maryanovsky
03/01/2024, 1:43 PMandylamax
03/01/2024, 1:44 PMAlexander Maryanovsky
03/01/2024, 1:44 PMmichaelv
07/03/2024, 7:30 AM./gradlew :composeApp:connectedAndroidTest
it runs the compose UI tests and that’s all good. But if I then run ./gradlew testDebugUnitTest
then it will try to run the compose UI tests also since they are in the same source set - but they will fail since it doesn’t have the dependencies for the UI test.
am I missing something or misunderstanding something or how to go about solving this?
one workaround I found is to exclude the test class but this is not ideal if I have to do that for every class.
allprojects {
tasks.withType<Test> {
if (name == "testDebugUnitTest") {
exclude("**/ExampleCommonComposeTest*")
}
}
}
I could create a subfolder inside commonTest for unit and ui and exclude the ui folder instead of each class but then it’s using a different package to the main source set. What is the best way? Maybe just need to have separate source sets in common.michaelv
07/05/2024, 1:40 AMmichaelv
07/09/2024, 12:44 AMAlexander Maryanovsky
07/09/2024, 8:52 AMmichaelv
07/09/2024, 9:39 AMJulian Pellico
03/26/2025, 10:30 PMandroidUnitTest
source set. Now it's a separate source set, but still has the same problem. of course, the reason the same problem happens is it runs the same task testDebugUnitTest
, so couldn't KMM project create a separate task to isolate the compose UI tests...?