What's the preferred way to mock/stub objects in robolectric tests?
My goal is to write Android code in TDD manner. Right now I am using interfaces and create mock classes that implement those interfaces in tests. This process is time consuming. Is there an easier way to stub a method of existing class in robolectric?
I can only post my opinion about that topic.
My preferred way is the MVP pattern.
the second point works great because robolectric deliver already "stub" classes. all what i can't check with pure android will be checkable with shadow classes.
But maybe you just search for the Shadow classes functionality, http://robolectric.org/custom-shadows/ where you can stub methods.
Update: here is also an example how I do it https://github.com/nenick/android-gradle-template/
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments