diff --git a/src/yunit/TestAdapter.cs b/src/yunit/TestAdapter.cs index 09cff8e..a145057 100644 --- a/src/yunit/TestAdapter.cs +++ b/src/yunit/TestAdapter.cs @@ -139,13 +139,13 @@ public void RunTests(IEnumerable tests, IRunContext runContext, IFrame foreach (var fileTests in fileSequentialTestsParallelTests.GroupBy(test => test.CodeFilePath)) { var testRuns = new ConcurrentBag(); - Parallel.ForEach(fileTests.SelectMany(fileTest => fileTests), test => testRuns.Add(RunTest(frameworkHandle, test, inOnlyMode))); + Parallel.ForEach(fileTests.ToArray(), test => testRuns.Add(RunTest(frameworkHandle, test, inOnlyMode))); Task.WhenAll(testRuns).GetAwaiter().GetResult(); } } var fileParallelTestsSequentialTests = groupTests.Where(group => group.Key == ParallelMode.FileParallelTestsSequential).SelectMany(group => group).ToArray(); - if (fileSequentialTestsParallelTests.Any()) + if (fileParallelTestsSequentialTests.Any()) { var testRuns = new ConcurrentBag(); foreach (var fileTests in fileParallelTestsSequentialTests.GroupBy(test => test.CodeFilePath).ToArray())