Add ControlledTestKit for simulated-time actor tests#45
Open
nb-ceffa wants to merge 1 commit into
Open
Conversation
Introduce a cross-platform cats-actors-testkit module built on Cats Effect TestControl. withActorSystemIO runs test logic under simulated time. Also extend the existing TestKit: - add expectMsgTypeSingle / expectMsgTypeCountN helpers - log the queue state when an expectMsg assertion fails - document the snapshot/splitAt race that makes expectMsgType flaky
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds a new cross-platform cats-actors-testkit module that lets you test actors under simulated time using Cats Effect's TestControl. Time-dependent behaviour (schedulers, receive timeouts,
retries) can be tested deterministically and instantly — no real-world sleeps, no flaky timing thresholds. Also includes a few quality-of-life improvements to the existing TestKit.
Motivation
Actor tests that involve delays currently have to sleep in real time, which makes suites slow and timing-sensitive. Cats Effect provides TestControl to drive an IO program over a simulated clock,
but wiring an ActorSystem into it correctly (execute → tick → interpret outcome) is fiddly boilerplate. This PR packages that pattern into a reusable, framework-agnostic helper.
What's included
Backward compatibility
Fully additive. The only change to existing code is in TestKit (new methods + extra logging + Scaladoc); no signatures changed and no behaviour removed.