Tuesday, February 24, 2026

Swift Testing With Event Streams

Matt Massicotte:

The original implementation used XCTestExpectation to do it. […] At first, I thought that I could use Swift Testing’s confirmation system to handle this.

[…]

But this had two problems. The obvious one is the nesting. I couldn’t figure out an easy way to avoid it. And in fact, my real code had even more callbacks than this.

The second was about ordering. As far as I can tell, there’s no way for me to distinguish here between “a-b” and “b-a”.

[…]

Eventually, someone else suggested I use an AsyncStream to capture events.

Previously:

Comments RSS · Twitter · Mastodon

Leave a Comment