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

Matti MK

02/22/2022, 1:30 PM
I’m starting to write tests for my compose UI. I plan to approach the testing from the perspective of unit testing, so testing different components of screens, and some screens in total, but not transitions, navigation and so on. So no E2E testing. I’ve been reading some blog posts and the docs, but would be happy to read on it more. Anyone happen to have good reference material, for example blog posts or projects to recommend? Thanks 👍
m

mattinger

02/22/2022, 2:13 PM
Have you tried the official developer guide yet: https://developer.android.com/jetpack/compose/testing? I think the one thing this glosses over is the use of the "testTag" modifier. It's akin to an ID in the view world, but purely used for the purpose of identifying nodes in a test scenario.
m

Matti MK

02/22/2022, 3:06 PM
Yep, I’ve read through it and actually already used a bit of the
testTag
in my experiments. I really don’t like to mix test specific code, like the tag, in production code so I’ve been doing it another way around
What I would be keen on seeing are extensive samples on testing and how they go about, for example, separating “unit tests” like testing a specific composable component from the typical more extensive UI testing