https://kotlinlang.org logo
Title
p

pajatopmr

02/15/2022, 6:39 AM
`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

olonho

02/15/2022, 8:54 AM
yes, work on better testing infra is planned, but no ETA at the moment. But feel free to contribute, we're fully OSS.
i

Igor Demin

02/15/2022, 9:02 AM
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:
@OptIn(org.jetbrains.compose.ExperimentalComposeLibrary::class)
implementation(compose.uiTestJUnit4)
3. You can track progress here.
p

pajatopmr

02/15/2022, 11:03 AM
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

Igor Demin

02/15/2022, 11:05 AM
find the ui-test module
It's in androidx repo
p

pajatopmr

02/15/2022, 11:19 AM
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

Igor Demin

02/15/2022, 11:51 AM
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:
./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

Kebbin

02/15/2022, 1:12 PM
Good work, all of you! 😎👍
o

olonho

02/15/2022, 1:13 PM
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

David Silber

02/16/2022, 2:29 AM
@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

pajatopmr

02/16/2022, 4:57 AM
@David Silber I did not know that assertExists() and assertDoesNotExist() worked! Good to know, so thanks for that.