I hereby absolve you of one piece of your async testing stress.

When you are testing "eventually X will be true," you can poll.

You do not have to create elaborate callback schemes.

You do not have to inject mocks that hide XCTestExpectations.

You do not have setup an AsyncStream or a Notification.

There is nothing wrong with asserting that something will eventually be true. It is exactly what you mean.

And in a unit test, there is nothing wrong with polling for that.

@cocoaphony
This is a post about me, I’m sure of it!
@cocoaphony I like that this completes immediately as opposed to some methods of testing async code out in the wild that have a mandatory minimum delay.
@sjs Yeah, I've been kind of surprised to see people willing to add Task.sleep in a test rather than just polling. (I don't even put a sleep in the loop. There's almost never a reason to unless you're very certain there's a minimum time to complete the operation.)