Hi, ncruch fails in the scenario described below.
xunit test:
public class UnitTest1
{
[Theory]
[MemberData(nameof(Inline))]
public void Test1(DateOnly date)
{
Assert.True(true);
}
public static IEnumerable<object[]> Inline()
{
yield return new object[] { DateOnly.MinValue };
}
}
Project:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<IsPackable>false</IsPackable>
<IsTestProject>true</IsTestProject>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.6.3" />
<PackageReference Include="xunit" Version="2.5.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.0">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="coverlet.collector" Version="6.0.0">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
</ItemGroup>
</Project>
Error:
An error occurred while analysing this project after it was built: System.Exception: Error while discovering test 'TestProject2.UnitTest1.Test1("0001-01-01")':System.Exception: Type 'System.DateOnly' is not marked as serializable. Resolution path =
System.DateOnly
at nCrunch.Common.Serialization.SerializationContractType..ctor(UInt16 typeId, Type type, IList`1 fields, Boolean isMarshalByRefType, Boolean hasPotentialInheritors, SerializationPath path, Boolean wasAddedDynamically)
at nCrunch.Common.Serialization.SerializationContract.AddTypeToContract(Type instanceType, Boolean isAddedDynamically)
at nCrunch.Common.Serialization.BinarySerializer.writeNewContract(SerializationContext context, Type instanceType)
at nCrunch.Common.Serialization.BinarySerializer.lookupAndWriteContractType(SerializationContext context, Type instanceType)
at nCrunch.Common.Serialization.BinarySerializer.WriteInstance(SerializationContext context, Object instance, Type knownInstanceType, Boolean cacheCollectionContents)
at nCrunch.Common.Serialization.BinarySerializer.Serialize(SerializationContext context, Object instance, Type knownInstanceType, Boolean cacheInstance, Boolean cacheCollectionContents)
at nCrunch.Common.Serialization.CustomTypeSerializers.ObjectArraySerializer.Serialize(SerializationContext context, SerializationContractType type, Object value, Boolean cacheCollectionContents)
at nCrunch.Common.Serialization.BinarySerializer.WriteInstance(SerializationContext context, Object instance, Type knownInstanceType, Boolean cacheCollectionContents)
at nCrunch.Common.Serialization.BinarySerializer.Serialize(SerializationContext context, Object instance, Type knownInstanceType, Boolean cacheInstance, Boolean cacheCollectionContents)
at nCrunch.Common.Serialization.BinarySerializer.Serialize(BufferWriter writer, Object instance, Type knownInstanceType, Boolean cacheInstance)
at nCrunch.Module.XUnit2.XUnitBinarySerializer.Serialize(BufferStream stream, Object graph)
at nCrunch.TestExecution.Frameworks.XUnit2.TestCaseArgumentData.StoreInTest(FrameworkTest test)
at nCrunch.Module.XUnit2.Integration.XUnitNCrunchDiscoveredTestContainer.StoreDiscoveredTest(ITestCase testCase, TestName testName)
at nCrunch.Module.XUnit2.Integration.XUnitDiscoveryMessageSink.discoverTest(ITestCase testCase)
at nCrunch.Module.XUnit2.Integration.XUnit2DiscoveryEnvironment.FindFrameworkTestsInAssembly(ReflectedAssembly assembly, FilePath assemblyFilePath, IList`1 referencedAssemblyFilePaths, ComponentUniqueName testComponentUniqueName, PlatformType platformType, DynamicProxy[] dynamicProxies)
at nCrunch.TestExecution.TestFinder.<>c__DisplayClass0_2.<FindTestsForFrameworks>b__1()
at nCrunch.Common.PerformanceTracking.PerfTracker.TrackActivity(String name, Action activity)
at nCrunch.TestExecution.TestFinder.<>c__DisplayClass0_0.<FindTestsForFrameworks>b__0()
at nCrunch.Common.PerformanceTracking.PerfTracker.TrackActivity(String name, Action activity)
at nCrunch.TestExecution.TestFinder.FindTestsForFrameworks(ReflectedAssembly assembly, FilePath assemblyFilePath, IList`1 referencedAssemblyFilePaths, DescribedTestFrameworkDiscoverer[] describedDiscoverers, ComponentUniqueName testComponentUniqueName, PlatformType platformType, DynamicProxy[] dynamicProxies)
at nCrunch.TestExecution.RemoteTaskRunner.AnalyseAssembly(DescribedTestFrameworkDiscoverer[] applicableFrameworks, ComponentUniqueName testComponentUniqueName, PerfTracker perfTracker, TaskLogId taskLogId)
It starts failing after updating xunit nugets to the latest version. It works with older xunit present in visual studio test template:
<PackageReference Include="xunit" Version="2.4.2" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5">
Could be worth mentioning that visual studio test runner works without any problems with latest version.