-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
API proposal: rewrite blocking elements of TestKit to return awaitable Tasks #3854
Comments
Honestly, I think we could greatly simplify the testkit AP - for example // equivalent of probe.ExpectNext
(await probe.NextAsync(cancellationToken)).Should().Be(new ExpectedMessage())
// equivalent of probe.FishForMessage
while (await probe.TryNextAsync(cancellationToken) && probe.LastMessage == new ExpectedMessage()); Of course, we could create a helper methods to simplify those patterns, but I've noticed that people on gitter are often asking how to do something, because the patterns and test kit methods don't feel familiar to them. Using async enumeration-like API is IMO very intuitive for them. There are also additional simplifications:
|
@Horusiath I agree that returning something that is more LINQ-like might be helpful, since that's familiar, intuitive, and flexible enough to support a wide variety of use cases. That in combination with something like FluentAssertions for doing nasty stuff like checking that the messages returned are all in a specific order, or at least 1 of them are found inside a collection, etc. I also think we'd need to launch a Roslyn analyzer embedded into the Akka.TestKit assembly to stop us from giving end-users enough rope to hang themselves. The fact that these methods will need to be Alternatively, if there's a way of forcing the current TestKit API to just |
Version: Akka.NET 1.5.0 and later
As part of the Akka.NET v1.4..0 sprint I've spent a lot of time going through our test suite and disabling parts of it that are especially timing-sensitive. I think the reasons for most of these races boils down to the following:
TestLatch.Ready
,ExpectMsg
,AwaitCondition
, etc.ExpectMsg<T>(TimeSpan.FromSeconds(300))
can succeed or fail depending on how many cores are available and wait the blocking state of the work queue looks like.async
andawait
instead, it could work with XUnit's ability to takeTask
off of the test method and would allow for background threads with work to do to run while foreground threads that are waiting on results are also unblocked.However, this comes with some flies in the ointment:
Task
everywhere.Task
off the top of each of its test methods, but what about NUnit, MsTest, and other test frameworks that we've supported historically? Where does that leave them?If we were going to introduce this, here is what I'd propose doing:
Task
- don't need to rename the method necessarily with theAsync
prefix, just need to add some overloads that return them.Either way, wanted to throw this idea out there for consideration in Akka.NET 1.5.0 and later. What are your thoughts?
The text was updated successfully, but these errors were encountered: