Hai,
Thanks for the comment. When I am testing the non-Android layers of my application (presentation, domain) I prefer to use real classes whenever possible.
Why? I find that using mock objects when not absolutely necessary couples your implementation to the public API of other internal classes. This makes for more brittle tests that need to be updated more frequently.
For example, what if we changed the add()
method to accept an array of values? Then the presenter tests would need to be updated as well as the Calculator
tests. Plus we still don’t know if the result returned is actually correct.
This blog post sums up the benefits of this approach best.