v2
v3
AOT
Warning
xUnit3007
"Test case implementation might not be serializable"
Cause
A violation of this rule occurs when a test case implementation might not be serializable.
Reason for rule
Test cases in v3 reflection-mode must be serializable, because their serializable contents are provided to VSTest so that they can later be run individually from Test Explorer.
How to fix violations
To fix a violation of this rule, either implement IXunitSerializable on the test case, or support its serialization with a third party class that implements IXunitSerializer.
Examples
Violates
using Xunit.v3;
public class xUnit3007 : IXunitTestCase
{
// ... implementation of IXunitTestCase ...
}
Does not violate
using Xunit.Sdk;
using Xunit.v3;
public class xUnit3007 : IXunitTestCase, IXunitSerializable
{
// ... implementation of IXunitTestCase ...
// ... implementation of IXunitSerializable ...
}
using Xunit.Sdk;
using Xunit.v3;
[assembly: RegisterXunitSerializer(typeof(xUnit3007Serializer), typeof(xUnit3007)]
public class xUnit3007 : IXunitTestCase
{
// ... implementation of IXunitTestCase ...
}
public class xUnit3007Serializer : IXunitSerializer
{
// ... implementation of IXunitSerializer ...
}