Is it possible to unit test models and classes tha...
# compose
t
Is it possible to unit test models and classes that define
mutableStateOf
s or other snapshot state APIs outside of an Android integration test? We are defining some models with snapshot state APIs that we would like to just have unit tests for, since we don’t have CI infra set up for Android integration tests.
z
snapshot state stuff doesn’t require any of the other compose stuff (compiler plugin, appliers, etc) so yes
👍🏼 1
a
I use
snapshotFlow {}
and
Snapshot.withMutableSnapshot {}
for this frequently
👍🏼 1
For consuming and producing controlled snapshot changes, respectively
🙏🏼 1
t
great, figured it should be possible but didn’t know exactly how. looking into using
snapshotFlow {}
in a unit test scenario now 🙏🏼
a
There are lower level ways to observe snapshots but snapshotFlow tends to do what I need for most testing scenarios
🙏🏼 1