Test method must have valid return type
A test method must have a valid return type.
For v2 tests, that includes void
and Task
. For v3 tests, you can also use ValueTask
.
xUnit.net will not run a test method with the wrong return type.
To fix a violation of this rule, use one of the supported return types.
All versions:
using Xunit;
public class xUnit1028
{
[Fact]
public int TestMethod()
{
return 42;
}
}
v2 only:
using System.Threading.Tasks;
using Xunit;
public class xUnit1028
{
[Fact]
public ValueTask TestMethod()
{
return default(ValueTask);
}
}
All versions:
using Xunit;
public class xUnit1028
{
[Fact]
public void TestMethod()
{
}
}
using System.Threading.Tasks;
using Xunit;
public class xUnit1028
{
[Fact]
public Task TestMethod()
{
return Task.CompletedTask;
}
}
v3 or later:
using System.Threading.Tasks;
using Xunit;
public class xUnit1028
{
[Fact]
public ValueTask TestMethod()
{
return default(ValueTask);
}
}