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

nglauber

07/22/2022, 2:31 PM
hey guys. can someone help me with unit tests in Compose + Coil image loading? I answered my own question here and I would like to know if I’m doing right… https://stackoverflow.com/questions/73044642/how-to-unit-test-if-an-image-was-loaded-using-coil-compose/73080538#73080538
y

yschimke

07/22/2022, 6:51 PM
If you want to avoid special syntax in your composables to hang your tests off, you could use EventListener.
n

nglauber

07/22/2022, 7:14 PM
Sorry, could you elaborate?
y

yschimke

07/22/2022, 8:32 PM
If you set an event listener on your test image loader, you can just see that you get a success result after its rendered.
Just another option.
n

nglauber

07/22/2022, 8:54 PM
I got your point. My question is: how can I get the
painter
object in the test, listen to state changes and do the assertion with the success state?
18 Views