C#C
C#4y ago
D.Mentia

❔ Task.WhenAll for Tests, and other async questions

In xUnit, there is no support for testing async or in parallel within the same collection, where a collection is basically tests that share a single startup and teardown
So I extended some xUnit classes, found where the tests are ran, and instead of awaiting each one in a loop, I start them all and then Task.WhenAll. This makes the tests really fast, and when they pass, verifies there are no concurrency issues

Why would this be a bad idea? I assume there must be a reason they did not do this by default

And, would this be considered Parallel? I always thought async and Parallel are different, even opposite things, but if not awaiting them immediately, then it is parallel, isn't it?



And lastly, should I do some sort of batching, or degrees of parallelism, when doing a large number of Task.WhenAll (in general)? Or is it just going to handle that performantly on its own?
Was this page helpful?