site/xunit.analyzers/rules/xUnit1049.md
A violation of this rule occurs when an async test method returns void.
Support for async void test methods has been removed in xUnit.net v3. This rule will only trigger
for v3 projects.
To fix a violation of this rule, change the test method return type to Task or ValueTask.
using Xunit;
public class TestClass
{
[Fact]
public async void TestMethod()
{
// ...
}
}
using System.Threading.Tasks;
using Xunit;
public class TestClass
{
[Fact]
public async Task TestMethod()
{
// ...
}
}
using System.Threading.Tasks;
using Xunit;
public class TestClass
{
[Fact]
public async ValueTask TestMethod()
{
// ...
}
}