1

This question already has an answer here:

Should every single class in my system have an interface?

I understand that interfaces provide an abstraction from the implementation of a class and so changes to the implementation do not affect classes that are using the interface, i.e. cross platform implementations may differ but the interface can stay the same.

But what about when testing? I want to test every class and function I write, and sometimes I want to mock classes that may use heavy resources like databases or third party web apis.

If I create an interface for every single class in my system I can easily create mocks and unit tests against the interfaces, and this will allow me to test all classes and functions in the system, but I feel like this is overkill.

Is there a more efficient way to get 100% coverage when testing a system, using unit tests and mocks, without creating interfaces for every single class?

marked as duplicate by Telastyn, user22815, gnat, Community Jan 19 '17 at 7:55

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.