Skip to content
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

Added handling of fixtures that implement IAsyncLifetime, IAsyncDisposable #6

Merged
merged 1 commit into from
Dec 7, 2021
Merged

Added handling of fixtures that implement IAsyncLifetime, IAsyncDisposable #6

merged 1 commit into from
Dec 7, 2021

Conversation

candoumbe
Copy link
Contributor

I took the liberty of opening this PR to fix #5
I also added parallelization

Hope this will help the community

…isposable`

Added parallelization of initialization and destruction of fixtures.
@JDCain
Copy link
Owner

JDCain commented Dec 6, 2021

Thank you for this! I failed to understand the issue the other person had posted.

I am not familiar with Parallel.ForEach() & .ForEachAsync(), why did you use it instead of something like Task.WhenAll() which is used in the XunitTestClassRunner?

@candoumbe
Copy link
Contributor Author

The idea behind using Parallel.ForXXX was just to parallelize initialization and destruction calls.
But yeah maybe this could go a step further and, when supported parallelize all possible tasks. But I wonder how to do this as not all things are asynchronous.

Could it be done as an improvement in an other PR ?

@JDCain JDCain merged commit 92be7fc into JDCain:master Dec 7, 2021
@candoumbe candoumbe deleted the feature/handle-asynclifetime-asyncdisposable-fixtures branch December 7, 2021 20:16
@siewers
Copy link

siewers commented Jan 6, 2022

I can see the usage of Parallel.ForEach was discussed here. This does not work and is currently broken in .NET 5 and below.
The alternative is to use Task.WhenAll, which in fact does work.
I haven't investigated how this works in .NET 6, where the Parallel.ForEachAsync exists, but this is not valid for earlier versions.

I can create a working PR for fixing the implementation in .NET 5 and below.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support for IAsyncLifetime
3 participants