首页 > 解决方案 > Visual Studio NUnit 适配器一次只能运行 10K 测试

问题描述

我正在使用带有 NUnit 3.10 的 VS 2017。我有一个具有约 50K 单元测试的解决方案。资源管理器窗口中的注册测试时间为 5-10 分钟(大多数测试不到一毫秒)。但是,在运行时,它实际上需要的时间比这要长得多。每进行 10,000 次测试,就会有一个长时间的停顿(几分钟),似乎什么也没发生。然后下一个 10K 开始,然后是另一个暂停,依此类推。

这是测试输出的示例,运行我的测试子集(其中约 26K)

[10/5/2018 10:19:05 AM Informational] ------ Run test started ------
[10/5/2018 10:19:12 AM Informational] NUnit Adapter 3.10.0.21: Test execution started
[10/5/2018 10:19:13 AM Informational] Running selected tests in C:\Users\kspeer\Documents\GitHub\CreatureGen\CreatureGen.Tests.Unit\bin\Debug\CreatureGen.Tests.Unit.dll
[10/5/2018 10:19:27 AM Informational] NUnit3TestExecutor converted 25908 of 25908 NUnit test cases
[10/5/2018 10:26:35 AM Informational] NUnit Adapter 3.10.0.21: Test execution complete
[10/5/2018 10:26:41 AM Informational] NUnit Adapter 3.10.0.21: Test execution started
[10/5/2018 10:26:41 AM Informational] Running selected tests in C:\Users\kspeer\Documents\GitHub\CreatureGen\CreatureGen.Tests.Unit\bin\Debug\CreatureGen.Tests.Unit.dll
[10/5/2018 10:26:56 AM Informational] NUnit3TestExecutor converted 25908 of 25908 NUnit test cases
[10/5/2018 10:34:14 AM Informational] NUnit Adapter 3.10.0.21: Test execution complete
[10/5/2018 10:34:19 AM Informational] NUnit Adapter 3.10.0.21: Test execution started
[10/5/2018 10:34:19 AM Informational] Running selected tests in C:\Users\kspeer\Documents\GitHub\CreatureGen\CreatureGen.Tests.Unit\bin\Debug\CreatureGen.Tests.Unit.dll
[10/5/2018 10:34:33 AM Informational] NUnit3TestExecutor converted 25908 of 25908 NUnit test cases
[10/5/2018 10:38:58 AM Informational] Running selected tests in C:\Users\kspeer\Documents\GitHub\CreatureGen\CreatureGen.Tests.Integration.IoC\bin\Debug\CreatureGen.Tests.Integration.IoC.dll
[10/5/2018 10:38:58 AM Informational] NUnit3TestExecutor converted 26 of 26 NUnit test cases
[10/5/2018 10:38:59 AM Informational] NUnit Adapter 3.10.0.21: Test execution complete
[10/5/2018 10:38:59 AM Informational] ========== Run test finished: 25932 run (0:19:54.0766142) ==========

测试资源管理器中的注册运行时间仅为 37 秒,而日志中为 21 分钟。

Explorer 中的测试计数和持续时间

为什么会这样?有什么我可以配置或做的事情来改善这一点吗?

更新 1:我使用 NUnit 控制台运行器运行了相同的测试,并且没有暂停。

NUnit 控制台运行器

更新 2:更有趣的是,我在 Visual Studio 2017 社区版中运行了测试,并没有看到暂停。我看到暂停的地方仅在 Visual Studio 2017 企业版中。

更新 3:如果您“全部运行”,则没有差距。如果你运行一个特定的项目,就会出现差距。

标签: c#unit-testingvisual-studio-2017nunit

解决方案


推荐阅读