Search code examples
android-jetpack-composeui-automationkotlin-multiplatformcompose-desktop

How to test Compose Multiplatform for Desktop interactively (i.e., not headless)


Is there a way to run tests with androidx.compose.ui.test interactively (i.e., so that I can see them running with my own eyes)? I’m having trouble with something and it would help to be able to see the UI as the test is trying to execute.

I tried adding a long Thread.sleep in case the test was running so quickly I never got to see anything, but still can't see the UI with a long sleep.

Thanks.


Solution

  • At least for now, it is not possible to see the UI when using androidx.compose.ui.test, since it tests Compose logic without window management.

    However, there is an internal Compose Desktop API available that allows running tests with Swing window management. Please note that this API is not officially exposed as Swing is considered an implementation detail. Nevertheless, you can try using this approach by copying the code (taking the license into account). This may provide a way to see the UI.