As part of process improvements we are trying to ensure that all our projects have suitable unit tests, as there is a bit of education required in house I am trying ascertain what exactly is the best way to ensure we are making our classes as 'testable' as possible.
I suspect that we will start moving down the Mock object route and with most examples I have seen they interfaces to mock the implementations of the objects. So my question is should we ensure that ALL classes have an interface from which they derive?
If not what would be the process you would suggest in identifying classes that should have interface to allow them to be mocked?
No. Having interfaces on all classes / objects will only create an unnecessary overhead without producing any extra benefit.
The general rule of thumb is that your classes should depend on abstractions rather than concrete implementations, so I would suggest using "dependencies" as a starting point and any class that is an external dependency to another class should implement an interface.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With