Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

DataRow tests with nullable enums fail to run
MatthewSteeples
#1 Posted : Thursday, September 22, 2022 2:46:02 PM(UTC)
Rank: Advanced Member

Groups: Registered
Joined: 10/28/2014(UTC)
Posts: 139
Location: United Kingdom

Thanks: 7 times
Was thanked: 18 time(s) in 16 post(s)
See https://github.com/Matth...les/NullableEnumDataRow for a repro

If you create a DataRow test with enum values and null is an acceptable value then NCrunch fails to run the test with a stack trace similar to the following

Quote:
System.ArgumentException: Object of type 'System.Int32' cannot be converted to type 'System.Nullable`1[NullableEnumDataRow.CountryCode]'.
at System.RuntimeType.TryChangeType(Object value, Binder binder, CultureInfo culture, Boolean needsSpecialCast)
at System.RuntimeType.CheckValue(Object value, Binder binder, CultureInfo culture, BindingFlags invokeAttr)
at System.Reflection.MethodBase.CheckArguments(StackAllocedArguments& stackArgs, ReadOnlySpan`1 parameters, Binder binder, BindingFlags invokeAttr, CultureInfo culture, Signature sig)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at System.Reflection.MethodBase.Invoke(Object obj, Object[] parameters)
at nCrunch.TestExecution.Reflection.Clr.ClrMethod.Invoke(Object instance, Object[] parameters)


The Visual Studio test runner has no problems with these tests and runs / reports on them fine
Remco
#2 Posted : Friday, September 23, 2022 5:25:44 AM(UTC)
Rank: NCrunch Developer

Groups: Administrators
Joined: 4/16/2011(UTC)
Posts: 7,144

Thanks: 959 times
Was thanked: 1290 time(s) in 1196 post(s)
Thanks for sharing this issue with the code sample.

I've reproduced it as described. I'm looking into this now to see what options we have for fixing this.

For the time being, I recommend switching your 'Framework utilisation type for MSTest' to 'DynamicAnalysis', as this has better support for data row tests.
Users browsing this topic
Guest
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

YAF | YAF © 2003-2011, Yet Another Forum.NET
This page was generated in 0.025 seconds.
Trial NCrunch
Take NCrunch for a spin
Do your fingers a favour and supercharge your testing workflow
Free Download