The release notes did say that `runComposeUiTest` ...
# compose
a
The release notes did say that
runComposeUiTest
can be written in commonMain, but when I ran those tests in android (
./gradlew :testDebugUnitTest
or
./gradlew testReleaseUnitTest
), I am getting
Copy code
Unresolved reference 'runComposeUiTest'
The same tests run fine on jvm target with (
./gradlew :jvmTest
) I did setup my dependencies in
commonTest
as show below,
Copy code
val commonTest by getting {
    dependencies {
        implementation(compose.uiTest)
    }
}
What am I doing wrong? using compose version 1.6.0
i
сс @Alexander Maryanovsky
a
Are you trying to run them on Android?
a
No, I thought
./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 dependencies
a
You can only run desktop tests locally.
well, and wasm tests
For android it needs the Android emulator, for iOS it needs the iOS simulator
a
wait, even the unit tests have to be ran on the device???
a
The compose UI tests can’t run as unit tests, they can only run as instrumented tests.
They can’t (currently) run with robolectric.
a
Thank you for that clarification then, I was pulling out my hair on this one
a
np
m
hi @Alexander Maryanovsky. what is the recommended way to add compose UI tests as described in that document without breaking the unit tests? i.e. if I run
./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.
Copy code
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.
anyone else know? what is the best way to do it? thanks. :)
seems to be a ghost town. 👻
a
I don’t know the answer, and the question isn’t really about Compose. You have two sets of tests in the same module and source-set, and you want to run them separately. It’s a question about gradle, or maybe the unit-testing framework.
👍 1
m
hmm ok. thanks for responding! I guess for now there’s no recommendation for compose multi-platform projects.