Build/Test Issues

DataRow tests with nullable enums fail to run

Started by MatthewSteeples on 1,763 views

See https://github.com/MatthewSteeples/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

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
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.

Post a reply

Log in to reply.