Rank: Newbie
Groups: Registered
Joined: 6/28/2023(UTC) Posts: 3 Location: Germany
|
We use MSTest for our unit tests and are unable to use NCrunch with some test assemblies, which use the DynamicDataAttribute to generate multiple test cases like this: Code:
[TestClass]
public class ExampleTests
{
public static IEnumerable<object[]> MyTestData
{
get
{
yield return new object[] { 1 , "one"};
yield return new object[] { 2 , "two"};
yield return new object[] { 3 , "three"};
}
}
[DataTestMethod]
[DynamicData(nameof(MyTestData))]
public void ExampleTest(int number, string word)
{
// ...
}
}
However, test assemblies using the DynamicDataAttribute can't be built/analyzed with the following error: Code:
An error occurred while analysing this project after it was built: System.InvalidOperationException: Sequence contains no matching element
at System.Linq.ThrowHelper.ThrowNoMatchException()
at System.Linq.Enumerable.First[TSource](IEnumerable`1 source, Func`2 predicate)
at nCrunch.Module.MSTest.Integration.MSTestDynamicDiscoverer.extractDynamicDataSourceFromMethodAttribute(ReflectedType fixtureType, ReflectedAttribute reflectedAttribute)
at nCrunch.Module.MSTest.Integration.MSTestDynamicDiscoverer.<>c__DisplayClass5_0.<FindFrameworkTestsInAssembly>b__1()
at nCrunch.Common.PerformanceTracking.PerfTracker.TrackActivity(String name, Action activity)
at nCrunch.Common.PerformanceTracking.PerfTracker.TryTrackActivity(String name, Action activity)
at nCrunch.Module.MSTest.Integration.MSTestDynamicDiscoverer.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)
I suspect is due to a recent change in the MSTest framework. They changed the namings of the internal fields (they added underscores, so dynamicDataSourceName became _dynamicDataSourceName etc.), but NCrunch appears to still be looking for the old naming. (for the changes see https://github.com/micro...1a7c2eab643c3fbb9532b9, src/TestFramework/MSTest.Core/Attributes/DataSource/DynamicDataAttribute.cs) Downgrading the packages MSTest.TestFramework and MSTest.TestAdapter to version 2.3.0-preview-20220810-02 seems to confirm this, as tests with DynamicTestAttribute work again. That build is from 8/10/2022, so before the naming change on 8/30/2022. Upgrading the packages to version 3.0.0-preview-20221110-04, released on 11/11/2022 breaks the NCrunch build again, just like the most recent version. We're using NCrunch 4.17.0.7 with Visual Studio 2022 17.6.
|