Visual Studio Version: VS2017
OS: W10
Test Framework: MSTest v2
I have the following test:
public abstract class UpdatableFieldTests<T> : GenericDealUpdatableFieldTests<T> where T : class, IUpdatableField
{
public static object[] InvalidDealTypes
{
get
{
var result=(from item in Enum.GetValues(typeof(DealType))
.OfType<DealType>()
where item != DealType.FixedFloat && item != DealType.FloatFloat
select new object[] { item }).ToArray();
return result;
}
}
[TestMethod]
[DynamicData(nameof(InvalidDealTypes))]
public void UserWithDealType_ForNonSwapDeals_ReturnsFalse(DealType dealType)
{
//Arrange
var field = GetTestInstance();
//Act
var result = field.UseWithDealType(dealType);
//Assert
Assert.IsFalse(result);
}
}
Other classes inherit from this base class and execute UserWithDealType_ForNonSwapDeals_ReturnsFalse. This worked fine for NCrunch 2.17 but is now breaking with:
System.InvalidOperationException: Late bound operations cannot be performed on types or methods for which ContainsGenericParameters is true.
at System.Reflection.RuntimeMethodInfo.ThrowNoInvokeException()
at System.Reflection.RuntimeMethodInfo.InvokeArgumentsCheck(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
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.Module.MSTest.Integration.MSTestDynamicDataSourceMethod.TryGetAllTestCaseParameters()
at nCrunch.Module.MSTest.Integration.MSTestTest.Run()
Build/Test Issues
Getting Generics error on 3.18.0.2 that wasn't there in 3.17.x
Started by GethinStevens on 4,178 views
Remco NCrunch Developer
#12558
17 Aug 2018 23:46 UTC
Hi, thanks for sharing this issue.
Support for DynamicDataAttribute is newly introduced in NCrunch v3.17. The reason you haven't seen this fail on older versions of NCrunch is likely because the test wasn't being detected and reported. At the time NCrunch 2.17 was released, MSTest v2 didn't exist yet.
This problem appears to be related to the dynamic data method being declared on a generic class. NCrunch will require a code fix to handle such a scenario (I'm assuming MSTest is currently OK with it). We'll look into this to see if such a fix is possible in a future release.
For the time being, I recommend avoiding the use of DynamicData methods on classes that make use of generics.
Support for DynamicDataAttribute is newly introduced in NCrunch v3.17. The reason you haven't seen this fail on older versions of NCrunch is likely because the test wasn't being detected and reported. At the time NCrunch 2.17 was released, MSTest v2 didn't exist yet.
This problem appears to be related to the dynamic data method being declared on a generic class. NCrunch will require a code fix to handle such a scenario (I'm assuming MSTest is currently OK with it). We'll look into this to see if such a fix is possible in a future release.
For the time being, I recommend avoiding the use of DynamicData methods on classes that make use of generics.
Remco NCrunch Developer
#12569
26 Aug 2018 23:13 UTC
Would you like to try the build below to see if this resolves the problem for you? This build contains a targeted fix for this issue.
NCrunch_Console_3.19.0.2.msi
NCrunch_Console_3.19.0.2.zip
NCrunch_GridNodeServer_3.19.0.2.msi
NCrunch_GridNodeServer_3.19.0.2.zip
NCrunch_LicenseServer_3.19.0.2.zip
NCrunch_VS2008_3.19.0.2.msi
NCrunch_VS2010_3.19.0.2.msi
NCrunch_VS2010_3.19.0.2.zip
NCrunch_VS2012_3.19.0.2.msi
NCrunch_VS2012_3.19.0.2.zip
NCrunch_VS2013_3.19.0.2.msi
NCrunch_VS2013_3.19.0.2.zip
NCrunch_VS2015_3.19.0.2.msi
NCrunch_VS2015_3.19.0.2.msi.7z
NCrunch_VS2015_3.19.0.2.zip
NCrunch_VS2017_3.19.0.2.msi
NCrunch_VS2017_3.19.0.2.msi.7z
NCrunch_VS2017_3.19.0.2.zip
NCrunch_Console_3.19.0.2.msi
NCrunch_Console_3.19.0.2.zip
NCrunch_GridNodeServer_3.19.0.2.msi
NCrunch_GridNodeServer_3.19.0.2.zip
NCrunch_LicenseServer_3.19.0.2.zip
NCrunch_VS2008_3.19.0.2.msi
NCrunch_VS2010_3.19.0.2.msi
NCrunch_VS2010_3.19.0.2.zip
NCrunch_VS2012_3.19.0.2.msi
NCrunch_VS2012_3.19.0.2.zip
NCrunch_VS2013_3.19.0.2.msi
NCrunch_VS2013_3.19.0.2.zip
NCrunch_VS2015_3.19.0.2.msi
NCrunch_VS2015_3.19.0.2.msi.7z
NCrunch_VS2015_3.19.0.2.zip
NCrunch_VS2017_3.19.0.2.msi
NCrunch_VS2017_3.19.0.2.msi.7z
NCrunch_VS2017_3.19.0.2.zip
Post a reply
Log in to reply.