Generic Protocols and Associated Types - Power Tools for Unit Testing
summary
Builds a small networking layer using Swift generics, protocols and AssociatedTypes so requests carry a concrete Success type that decodes from JSON, and shows how URLSession implements protocol extensions. Demonstrates using primary associated type to let "any" protocol preserve a request type, contrasts any vs some for parameters and returns, and implements a mock generic session with a closure plus XCTest expectations to verify headers, URL components and decoded responses — tests run without real networking.
AI-written summary · about
chapters (13)
- 0:00Introduction and welcome
- 1:07About the speaker
- 2:58What generics provide
- 6:49Protocols and polymorphism
- 8:12Strongly typed networking
- 10:37Separating ideas from implementation
- 13:47Associated types in protocols
- 15:57Abstracting networking layer
- 17:02Protocol return type issues
- 19:30Primary associated types
- 21:38Mocking for unit testing
- 23:23Flexibility in testing
- 24:27Key takeaways summary








