has anyone found a way to do end to end UI testing...
# compose-desktop
a
has anyone found a way to do end to end UI testing with compose multi-platform? Something like espresso on Android?
a
What’s missing from the test API?
Except that it’s desktop-only atm, that is.
a
I was under the impression it was for unit testing, not running the real app and clicking buttons like what espresso would allow?
a
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
t
I'm not sure if this is your intention, but you can use
runDesktopComposeUiTest()
. Here's an example: MainKmpTest.kt
a
That runs the same thing underneath. It doesn’t open a real window. But you can actually open a real window, just use
Window
in your content:
Copy code
rule.setContent {
            Window(
                onCloseRequest = {},
                state = WindowState(size = DpSize(500.dp, 300.dp))
            ) {

            }
        }
BUT we’ll probably remove that (by having
Window
create a fake window) soon.
a
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
a
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
@Before
function and cleanup in an
@After
function.
Put your setup in a separate function you call from
main
and call that function both from main and from the test setup function.