Shaheer Muzammil

03/24/2022, 1:26 PM
Hey Guys, I have recently started using Compose and I was using previews to show different states of my views. Now Most of my classes in the application are abstractions so I was able to generate mocks for them and use them accordingly to show different states. but in case some of the final classes that I am using have their constructors as internal. as they should not be initialized from outside of the module. How do I use them? and is this the right approach to make these extensive previews? And should I use mocking libraries like Mokito or Mockk to get this done?

Zach Klippenstein (he/him) [MOD]

03/24/2022, 3:20 PM
Previews typically live not only in the same module but even the same file as the composables they’re previewing, so can call internal code just fine.

Shaheer Muzammil

03/25/2022, 6:48 AM
Ok and what is you opinion about using mocks over repositories and Use-cases just for previews? is it an overkill and should we be using mocking libraries and doubles in our main packages? Though they would not be a part of release builds after applying proguard


03/25/2022, 6:03 PM
i don’t understand why you have usecases in your UiLayer. You composable functions should receive state only.

Shaheer Muzammil

03/28/2022, 7:13 AM
Yup you are right. I am breaching layer boundaries. Thank you for the helping me realise that 👍
👍 1