apple / swift-async-algorithms

Async Algorithms for Swift
Apache License 2.0
3.03k stars 151 forks source link

Tools for testing Swift concurrency #157

Open stephencelis opened 2 years ago

stephencelis commented 2 years ago

A couple of weeks ago I brought up on the forums that it's basically impossible to write reliable tests for concurrent code: https://forums.swift.org/t/reliably-testing-code-that-adopts-swift-concurrency/57304

This repo has a bunch of internal code that aids in testing isolated async code, e.g. its sequences, in predictable, reproducible, and fast ways. This includes custom clocks, executors, and more.

Tools like these would ideally be more widely available to users that want to test async code, and should be extracted from this repo. They still won't make it possible to test async code that is threaded between actors, but hopefully this issue is also on Apple's radar, and a solution is in the works.

phausler commented 2 years ago

The first step of this is done; extracting the support into it's own package. I think the next step is to isolate more general purpose items and codify those into a maintainable general purpose testing infrastructure.

adhityasp commented 3 months ago

Any updates for more stable unit test?

Esquilli commented 2 months ago

Bumping this