~/talk

Testing Asynchronous Code in Swift 5.5

Talkat SwiftLeeds 2022 · on Thursday, 2022-10-20· [testing, concurrency]
links:none on file
slides:none on file

Refactors a Combine-based app to Swift 5.5 concurrency, showing concrete testable changes: replacing completion handlers with async/await, using withCheckedContinuation to test existing Combine or escaping-completion code without changing it, mocking network calls via AsyncStream plus a URLProtocol interceptor, and a reusable timeout Task that phases out waitForExpectations. Demonstrates parsing 999 meme templates down to ~799, running async let/sink let to observe effects, and when tests hang how to cancel or finish continuations so failures are meaningful.

AI-written summary · about

  1. 0:00Introduction and background
  2. 1:44Refactoring from Combine to async/await
  3. 6:08Testing structured concurrency basics
  4. 9:22Challenges with async/await in XCTest
  5. 14:14Testing tasks and cancellation
  6. 19:41Using task continuation for legacy code
  7. 20:02Mocking network calls with async stream
  8. 27:49Implementing timeout for async tests
  9. 29:55Final thoughts and future of async testing
~/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.