has anyone found a way to do end to end UI testing...
# compose-desktop
has anyone found a way to do end to end UI testing with compose multi-platform? Something like espresso on Android?
What’s missing from the test API?
Except that it’s desktop-only atm, that is.
I was under the impression it was for unit testing, not running the real app and clicking buttons like what espresso would allow?
We’re considering adding that option too, but it’s rarely needed. Nothing should prevent you from setting your entire app’s content composable as the test content, and “clicking” the buttons.
👍 1
I'm not sure if this is your intention, but you can use
. Here's an example: MainKmpTest.kt
That runs the same thing underneath. It doesn’t open a real window. But you can actually open a real window, just use
in your content:
Copy code
rule.setContent {
                onCloseRequest = {},
                state = WindowState(size = DpSize(500.dp, 300.dp))
            ) {

BUT we’ll probably remove that (by having
create a fake window) soon.
oh interesting, maybe this would work for me, I'll have to give it a try, thanks!
For this to be a real end-to-end test I basically want to run my main() func though, since theres lots of setup in there, so I'm not sure this will do exactly what I want
my app does a lot with the file system, so i'd really like to be able to test by using test code to click buttons, and then verify the filesystem has been modified appropriately
if you are familiar with selenium for web UI testing, or espresso for Android
I’m in the process of testing my app too, and it also has some setup it needs to run. I wrote a base class for tests and put the setup in a
function and cleanup in an
Put your setup in a separate function you call from
and call that function both from main and from the test setup function.