Search code examples
c#xunitxunit.netxunit2

xUnit Assert.All() async


I have this example test using xUnit:

    [Fact]
    public void SomeTest()
    {
        Assert.All(itemList, async item=>
                {
                    var i = await Something(item);
                    Assert.Equal(item,i);
                });
    }

Is there a good solution to make the whole test async/awaitable?


Solution

  • As for 2023, accepted answer is no longer true, xunit team added Assert.AllAsync: https://github.com/xunit/xunit/discussions/2498