1 of 10

UI tests with Compose

By Moro

2 of 10

Shrek, Compose functions are the future!

Shrek, do you know something about testing?

Shrek, let’s try to test a Composable function..

Shrek, are you here?

3 of 10

FINE…

Let’s test a composable function.

4 of 10

According to the spec, we need to add the dependencies…

  • libs.versions.toml
  • build.gradle.kts (app module)

5 of 10

Sherek, before you ask, I found a composable function to test…

6 of 10

It is an app bar. I want to test the following behaviors:

  • There is a back event, the left arrow icon appears;
  • There is no back event, the left arrow icon doesn’t appear.

7 of 10

FINE…

�Let’s do it.

We need to create a class defining the compose test rule.

Shrek, it is so beautiful. Is it a dream?

8 of 10

First test, we need to test if our Composable function is showing the button when there is a valid event…

9 of 10

Second test, we need to test if our Composable function hides the button when no event is passed…

10 of 10