<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/testing-with-event-streams-0jbmyauar" -->

---
title: Testing with Event Streams | daily.dev
description: Migrating tests from XCTest to Swift Testing revealed a challenge: verifying ordered callback sequences. XCTestExpectation handled this well, but Swift...
canonical: https://daily.dev/posts/testing-with-event-streams-0jbmyauar
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: Testing with Event Streams | daily.dev
og:description: Migrating tests from XCTest to Swift Testing revealed a challenge: verifying ordered callback sequences. XCTestExpectation handled this well, but Swift...
og:url: https://daily.dev/posts/testing-with-event-streams-0jbmyauar
og:image: https://api.daily.dev/og/posts/0jBMYAUAR.png
og:image:alt: Testing with Event Streams
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Testing with Event Streams

**[Matt Massicotte](https://daily.dev/sources/massicotte)** · 4 min read · 0 upvotes · 0 comments

## Summary

Migrating tests from XCTest to Swift Testing revealed a challenge: verifying ordered callback sequences. XCTestExpectation handled this well, but Swift Testing's confirmation API has nesting issues and no built-in ordering guarantees. The solution uses AsyncStream to capture events as they occur, with custom AsyncSequence extensions (collect and collectUntil) to retrieve and verify event sequences. A lightweight EventStream wrapper type reduces boilerplate and handles stream termination and sentinel values. The post also addresses when a simpler array-based approach works and when it doesn't, particularly around actor isolation and non-deterministic timing.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://massicotte.org/blog/testing-event-stream>

## Similar posts on daily.dev

- [Swift Testing — Hopes Entrusted to the Future](https://daily.dev/posts/swift-testing-hopes-entrusted-to-the-future-mjeviiebe) · Medium · 0 upvotes · 0 comments
- [Swift Testing explained with code examples](https://daily.dev/posts/swift-testing-explained-with-code-examples-pgxkvbvk5) · SwiftLee · 1 upvotes · 0 comments

---

Tags: [#swift](https://daily.dev/tags/swift)

[View this post on daily.dev](https://daily.dev/posts/testing-with-event-streams-0jbmyauar)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"TechArticle","headline":"Testing with Event Streams","url":"https://daily.dev/posts/testing-with-event-streams-0jbmyauar","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/testing-with-event-streams-0jbmyauar"},"datePublished":"2026-08-02T07:15:17.138Z","dateModified":"2026-08-02T07:35:34.670Z","description":"Migrating tests from XCTest to Swift Testing revealed a challenge: verifying ordered callback sequences. XCTestExpectation handled this well, but Swift...","image":"https://media.daily.dev/image/upload/s--ZrL_HSsR--/f_auto/v1722860399/public/Placeholder%2006","thumbnailUrl":"https://media.daily.dev/image/upload/s--ZrL_HSsR--/f_auto/v1722860399/public/Placeholder%2006","isAccessibleForFree":true,"articleSection":"Matt Massicotte","inLanguage":"en","publisher":{"@type":"Organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180}},"author":{"@type":"Organization","name":"Matt Massicotte","logo":"https://media.daily.dev/image/upload/logos/placeholder.jpg","url":"https://daily.dev/sources/massicotte"},"commentCount":0,"discussionUrl":"https://daily.dev/posts/testing-with-event-streams-0jbmyauar","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":0},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":0}],"keywords":"swift","timeRequired":"PT4M"}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"Matt Massicotte","item":"https://daily.dev/sources/massicotte"},{"@type":"ListItem","position":3,"name":"Testing with Event Streams"}]}
```

