~/talk

Generic Protocols and Associated Types - Power Tools for Unit Testing

Talkat Swift Heroes 2023 · 2023-05-04..05-05· [testing, swift]
name:Leo Dion
links:none on file
slides:none on file

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

  1. 0:00Introduction and welcome
  2. 1:07About the speaker
  3. 2:58What generics provide
  4. 6:49Protocols and polymorphism
  5. 8:12Strongly typed networking
  6. 10:37Separating ideas from implementation
  7. 13:47Associated types in protocols
  8. 15:57Abstracting networking layer
  9. 17:02Protocol return type issues
  10. 19:30Primary associated types
  11. 21:38Mocking for unit testing
  12. 23:23Flexibility in testing
  13. 24:27Key takeaways summary
~/search
type to search 6,249 conferences, 138,987 speakers and 185,172 talks
~/help
cmdctrl k
search every conference, speaker and series
/
focus the filter search
h
home
c
conferences
s
speakers
e
series
t
light / dark — the status bar button does the same
?
this help
esc
close this, then clear every filter — or just the search, while you are typing in it

Ignored while you are typing. Pages without a filter rail have no search to focus.