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.
Build/Test Issues
DateOnly serialization issue with latest xunit
Started by gieniowski on 2,261 views
Remco NCrunch Developer
#16769
21 Jul 2023 13:30 UTC
Hi,
Thanks for sharing this issue. I'll take a closer look and will get back to you soon.
Thanks for sharing this issue. I'll take a closer look and will get back to you soon.
Thanks Remco!
Just realized that I have forgot to mention that I am using visual studio 2022 and tried it with two versions of nCrunch: 4.17.0.7 and 4.18.0.3.
Just realized that I have forgot to mention that I am using visual studio 2022 and tried it with two versions of nCrunch: 4.17.0.7 and 4.18.0.3.
Remco NCrunch Developer
#16771
22 Jul 2023 11:22 UTC
Could you try the build below and let me know if this solves the problem for you?
NCrunch_Console_4.19.0.1.msi
NCrunch_Console_4.19.0.1.zip
NCrunch_GridNodeServer_4.19.0.1.msi
NCrunch_GridNodeServer_4.19.0.1.zip
NCrunch_LicenseServer_4.19.0.1.zip
NCrunch_VS2010_4.19.0.1.msi
NCrunch_VS2010_4.19.0.1.zip
NCrunch_VS2012_4.19.0.1.msi
NCrunch_VS2012_4.19.0.1.zip
NCrunch_VS2013_4.19.0.1.msi
NCrunch_VS2013_4.19.0.1.zip
NCrunch_VS2015_4.19.0.1.msi
NCrunch_VS2015_4.19.0.1.msi.7z
NCrunch_VS2015_4.19.0.1.zip
NCrunch_VS2017_4.19.0.1.msi
NCrunch_VS2017_4.19.0.1.msi.7z
NCrunch_VS2017_4.19.0.1.zip
NCrunch_VS2019_4.19.0.1.msi
NCrunch_VS2019_4.19.0.1.msi.7z
NCrunch_VS2019_4.19.0.1.zip
NCrunch_VS2022_4.19.0.1.msi
NCrunch_VS2022_4.19.0.1.msi.7z
NCrunch_VS2022_4.19.0.1.zip
NCrunch_Console_4.19.0.1.msi
NCrunch_Console_4.19.0.1.zip
NCrunch_GridNodeServer_4.19.0.1.msi
NCrunch_GridNodeServer_4.19.0.1.zip
NCrunch_LicenseServer_4.19.0.1.zip
NCrunch_VS2010_4.19.0.1.msi
NCrunch_VS2010_4.19.0.1.zip
NCrunch_VS2012_4.19.0.1.msi
NCrunch_VS2012_4.19.0.1.zip
NCrunch_VS2013_4.19.0.1.msi
NCrunch_VS2013_4.19.0.1.zip
NCrunch_VS2015_4.19.0.1.msi
NCrunch_VS2015_4.19.0.1.msi.7z
NCrunch_VS2015_4.19.0.1.zip
NCrunch_VS2017_4.19.0.1.msi
NCrunch_VS2017_4.19.0.1.msi.7z
NCrunch_VS2017_4.19.0.1.zip
NCrunch_VS2019_4.19.0.1.msi
NCrunch_VS2019_4.19.0.1.msi.7z
NCrunch_VS2019_4.19.0.1.zip
NCrunch_VS2022_4.19.0.1.msi
NCrunch_VS2022_4.19.0.1.msi.7z
NCrunch_VS2022_4.19.0.1.zip
Yup, did the test. Works now, thank you!
Post a reply
Log in to reply.