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

streetsofboston

05/12/2019, 1:07 PM
Currently, in a lot of our Android apps, our ViewModels emit sealed data-class instances that closely match the UI (Views), minimizing the code in the UI (Activities, Fragments). These sealed data-classes are very easy to test in plain unit-tests, since they have no dependencies on the Android platform. My question is: Will/does Compose generate instances of classes that are very easy to unit-test as well?
👍 2
r

romainguy

05/12/2019, 5:38 PM
Which generated instances are you talking about? @Model classes?
s

streetsofboston

05/12/2019, 6:10 PM
Yep. The
@Model
classes and maybe even
Compoments
or other variations of a composable functions. Would it be possible to write plain unit tests to inspect/assert/verify those?
r

romainguy

05/12/2019, 6:15 PM
@Model classes are just data classes (or should be)
For testing in general we have something called Semantics that will also be used for a accessibility and other tasks that require extracting information from the UI (assistants)
l

Leland Richardson [G]

05/12/2019, 6:32 PM
testing composables should not require any android platform dependencies, so this will be preserved, yes. For testing them, we will be providing some test contexts to compose into and then assert on the result, however if the trees you are producing have android views (as opposed to just compose UI), then you will still have to have an android platform dependency
👍 9
👌 1
s

streetsofboston

05/12/2019, 6:34 PM
Thank you, @romainguy and @Leland Richardson [G] !
5 Views