https://kotlinlang.org logo
#compose
Title
# compose
a

agrosner

05/20/2022, 3:01 PM
Testing - the official docs on compose recommend we run AndroidTest for our composables that run on a device. Also i have seen people mention robolectric in this channel to run a bunch of tests quickly. We have a lot of modules in our company and CI would not efficiently handle all of the tests to run often on PRs with many or any emulators. 1. should we use robolectric even if its not perfect? 2. is there movement on making official headless compose unit tests that dont need a physical device (outside of robolectric) to verify basic ui interactions or snapshots
m

madisp

05/20/2022, 3:14 PM
hey, IMHO for UI stuff you want to keep using espresso or something similar
for many modules and many tests have you considered cloud testing tools like firebase test lab?
d

dorche

05/20/2022, 4:24 PM
I've not had a chance to play with it but https://github.com/cashapp/paparazzi
m

madisp

05/20/2022, 4:24 PM
paparazzi is great for screenshot testing indeed
d

dorche

05/20/2022, 4:28 PM
Can you share any thoughts about it? How does it do the rendering? I'm thinking for a full compose app you could iterate over all your Previews and use paparazzi to generate screenshot tests? I've used facebook's "shot" library before, how does it compare?
m

madisp

05/20/2022, 4:29 PM
I've only used it for normal layouts and afaik paparazzi is based on
layoutlib
(the renderer in Android Studio)
👍 1
a

agrosner

05/20/2022, 5:56 PM
We could consider that. But right now it's not an option. Good to cast a wide net on speed and performance too
Paparrazi does that work with compose?
Snapshot testing on compose could capture instructions and instead of executing them, serialize them either just compose hierarchy with parameters passed in (similar to jest + shallow snapshots on web)
d

dorche

05/20/2022, 6:23 PM
Yeah Paparazzi has added compose support lately (as I said I’ve not tried it out yet, still using Shot). Serializing is a good shout, I’d be interested in how that turns out. In my current setup, the only instrumentation tests I have are snapshot tests (with the argument that all the logic is already covered by Unit Tests and given the State nature of Compose, a snapshot test for each State gives me enough confidence in the UI and I get all that for free from the Previews). No espresso faff either…
a

agrosner

05/20/2022, 6:27 PM
Where do you see that? I don't see it in. Their changelogs
d

dorche

05/20/2022, 6:31 PM
You'll need to use the snapshots repo, think its only from v1.0.0 onwards https://github.com/cashapp/paparazzi/pull/371
🙏 1
3 Views