`checkIsDisplayed()`not implemented? I found this ...
# compose-desktop
p
`checkIsDisplayed()`not implemented? I found this article on Desktop Compose layout testing which looks to provide the exact solution I need for testing with non-Android Desktop Compose. When I run the code (see below) it looks an awful lot like some needed code is not written yet. Can someone from JetBrains elaborate and answer the questions: 1. Is the code necessary for the test to work in fact not implemented, in which case, can I do anything to help get it implemented? 2. Perhaps I am using an invalid mix of versions; is my build.gradle.kts file correct? If not, which part did I get wrong? 3. @olonho is there a road map for Compose Desktop testing infrastructure available for public consumption? 4. I'm guessing that for Compose UI testing today, Android is the only game in town. Would that be a good guess?
o
yes, work on better testing infra is planned, but no ETA at the moment. But feel free to contribute, we're fully OSS.
i
1. It is necessary only for some functions you are using. For example, for
assertIsDisplayed
2. the
build.gradle
is correct. By the way, there is a shortcut for ui-test module:
Copy code
@OptIn(org.jetbrains.compose.ExperimentalComposeLibrary::class)
implementation(compose.uiTestJUnit4)
3. You can track progress here.
p
Very cool. Thank you both. @Igor Demin Where do I find the ui-test module? Doing a simple search for ui-test in the compose-jb repo is showing only references in files.
i
find the ui-test module
It's in androidx repo
p
Is there a contributing doc I should be reading? I am trying to map ...DesktopAssertions_desktopKt to a file in the androidx repo and struggling big time.
i
If you want to contribute, you need to send changes to aosp repo (not to our fork on GitHub). The majority of desktop source code is placed there, and we periodically fetch these changes, and apply our own internal patches. There is a doc how to contribute to aosp. After downloading Compose sources, you should add Gradle property to `~/.gradle/gradle.properties`:
androidx.compose.multiplatformEnabled=true
After that you can open sources in Android Studio via command
./gradlew studio
To run some test, use this command:
Copy code
./gradlew desktopTest --tests "androidx.compose.ui.input.mouse.MouseHoverFilterTest"
After you prepare a change and it is ready for review, you can ask for the review on JB side (me or Nikolay, for example). After our review, we will add reviewers from Google.
k
Good work, all of you! 😎👍
o
actually it's OK to send PR to https://github.com/JetBrains/androidx (after accepting Google's CLA) and we could upstream it eventually
d
@pajatopmr Thank you for posting this. I've been scrounging for information on how to set up testing for Compose Desktop without success. Your examples have helped me get to the point of having a running test! Of course
assertIsDisplayed()
gives me that "An operation is not implemented." message, but
assertExists()
and `assertDoesNotExist()`work fine. It is a start!
p
@David Silber I did not know that assertExists() and assertDoesNotExist() worked! Good to know, so thanks for that.