DEV Community

Discussion on: Code Smell 135 - Interfaces With just One Realization

Collapse
 
mcsee profile image
Maxi Contieri

I agree with you testability is one of the most important quality attributes of a system.
Test doubles decrease the confidence of a system since you are not testing a real one.
If you need to isolate your system you can build an interface and have two implementations: one for real and one for testing. Therefore you don't have just one realization. You have two. And you are no longer in code smell scenario

That said. Your last paragraph is the most important

Collapse
 
explorer14 profile image
Aman Agrawal • Edited

How is creating an implementation for testing, not a test double?

Thread Thread
 
mcsee profile image
Maxi Contieri

You need to use real objects for testing, not mock or test objects

Thread Thread
 
explorer14 profile image
Aman Agrawal

Interfaces for external dependencies allow you the flexibility of using either a test double or a real implementation without much overhead. Arguing about that is a moot point.

There is a lot to be said about levels and granularity of testing but that's not this post!

Thread Thread
 
mcsee profile image
Maxi Contieri

Right! there also a lot of test smells, many on this series and many others to come!