Xunit: Add Support for IAsyncDisposable to Dispose of Test Resources

Created on 26 Sep 2019  路  3Comments  路  Source: xunit/xunit

netcoreapp3.0 or netstandard3.0 they added IAsyncDisposable. It would be nice if xUnit supported asynchronous disposal of test classes and called DisposeAsync, just like it supports calling Dispose today for IDisposable.

```c#
public class FooTest : IAsyncDisposable
{
[Fact]
public void Foo_When_Then()
{
// ...
}

public ValueTask DisposeAsync()
{
    // ...
}

}
```

Most helpful comment

I understand. I'm offering you a mechanism that already works today so you don't have to wait.

All 3 comments

This is already supported today through IAsyncLifetime, for test classes and fixtures.

I think it's also useful to use the built-in types which will eventually become the defacto standard for disposing of objects asynchronously. It's also more discoverable.

I understand. I'm offering you a mechanism that already works today so you don't have to wait.

Was this page helpful?
0 / 5 - 0 ratings