Skip to content

Commit

Permalink
Fsdk.Tests: fix flaky WhenAnyAndAll test
Browse files Browse the repository at this point in the history
Introduced error margin for minimal run time in
"basic test for WhenAnyAndAll" to eliminate random failures.
  • Loading branch information
webwarrior-ws authored and knocte committed Jan 15, 2023
1 parent b07af48 commit 2809b9f
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion Fsdk.Tests/AsyncExtensions.fs
Original file line number Diff line number Diff line change
Expand Up @@ -213,8 +213,14 @@ type AsyncExtensions() =
FSharpUtil.AsyncExtensions.WhenAnyAndAll [ longJob; shortJob ]
|> Async.RunSynchronously

let timingErrorMargin = TimeSpan.FromMilliseconds 5.0
Assert.That(stopWatch.Elapsed, Is.LessThan longTime)
Assert.That(stopWatch.Elapsed, Is.GreaterThan shortTime)

Assert.That(
stopWatch.Elapsed,
Is.GreaterThan(shortTime - timingErrorMargin)
)

let results = subJobs |> Async.RunSynchronously
Assert.That(results.Length, Is.EqualTo 2)
Assert.That(results.[0], Is.EqualTo longJobRes)
Expand Down

0 comments on commit 2809b9f

Please sign in to comment.