Hello everyone, can I test my app without Mockito ...
# android
Hello everyone, can I test my app without Mockito and use only Espresso and JUnit?
😶 3
Sure. Mock is only one type of test double. In my projects I prefer to use Mocks only for classes that I have no control. For all other classes, I prefer using Fakes. I strongly recommend reading this article: https://martinfowler.com/articles/mocksArentStubs.html
Recently I also wrote about not using mocks, based on this article from Fowler and some video discussions with Kent Beck. https://dev.to/igorescodro/lessons-learned-with-software-testing-19lj
And what are the most popular Testing tools? Mockito, Espresso and JUnit?
I am sure there are more, but these 3 come quickly to mind: • Mockk (https://mockk.io/) handles coroutine testing better than Mockito. • We use Turbine (https://github.com/cashapp/turbine) for testing our Flows. • The Room test helper (https://developer.android.com/training/data-storage/room/migrating-db-versions#single-migration-test) is really nice when it comes to database migration testing.
Write your own fakes, don't use mockito, you'll thank me later
@ursus Please, say the advantages of fakes?
With fakes you are asserting end state, which is what matters; not the way you got there (which is what mockito asserts)