From 5145d945cde13e8ddd21d86be6aacb3423956c49 Mon Sep 17 00:00:00 2001 From: Jiapeng Xu Date: Tue, 24 Oct 2023 18:34:05 +0800 Subject: [PATCH] Fix parallel mode bug --- src/yunit/TestAdapter.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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())