📈 Unit Testing in Swift: Proper Architecture

Be In Control!

Class A depending on class B, depending on class C.
Testing class A requires isolation by mocking the class B dependency. Likewise, in order to test class B, we must isolate it by mocking the class C dependency.

Isolating Testable Classes

Dependency Injection

It’s just a Façade

Facades of classes B and C.
Concrete implementations of A, B and C using the dependency injection and facade patterns.

A note on Singletons

Next step: Mocking!

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store