Conversation
64a76f8 to
c4e2209
Compare
There was a problem hiding this comment.
Pull request overview
Adjusts async verification tests to properly track and shut down background producer tasks, preventing lingering work after assertions complete.
Changes:
- Capture the
Task.Run(...)task instead of discarding it. - Cancel the
CancellationTokenSourceandawaitthe background task to ensure it completes.
Comments suppressed due to low confidence (2)
Tests/Mockolate.Tests/Verify/VerificationResultTests.AsyncTests.cs:69
- Cancellation/await of the background Task only happens after the assertion succeeds. If VerifyAsync/That throws, the loop keeps running and can leak work into other tests (and potentially prolong the test run). Consider wrapping the verification in try/finally so you always cancel the CTS and await the task.
await That(((IAsyncVerificationResult)result).VerifyAsync(l => l.Length > 20)).IsTrue();
cts.Cancel();
await backgroundTask;
Tests/Mockolate.Tests/Verify/VerificationResultTests.AsyncTests.cs:165
- Cancellation/await of the background Task happens after the verification call. If AtLeastOnce throws, the task will keep running (up to ~10s) and can bleed activity into subsequent tests. Consider using try/finally to always cancel and await the task even when the verification fails.
Stopwatch sw = Stopwatch.StartNew();
sut.VerifyMock.Invoked.Dispense(Match.AnyParameters()).Within(TimeSpan.FromMilliseconds(500))
.AtLeastOnce();
sw.Stop();
cts.Cancel();
await backgroundTask;
|
🚀 Benchmark ResultsDetails
|
|
This is addressed in release v1.5.0. |



Adjusts async verification tests to properly track and shut down background producer tasks, preventing lingering work after assertions complete.
Changes:
Task.Run(...)task instead of discarding it.CancellationTokenSourceandawaitthe background task to ensure it completes.