首页 > 解决方案 > 项目中的每个测试都说“从实时单元测试中排除”?

问题描述

我根据文档https://docs.microsoft.com/en-us/visualstudio/test/live-unit-testing-faq?view=vs-2017添加了测试适配器和框架包。

我在每个测试旁边看到“烧杯”符号\图标,但悬停表示它已从实时单元测试中排除。

测试都可以手动运行,我尝试右键单击并告诉它包含,但什么也没做。我这里没有代码手动排除任何东西......

.net 4.7.1 项目

编辑

有错误

[10:03:48.205 错误] [TestRunner 1] 调用执行程序“executor://mstestadapter/v2”时发生异常:无法加载文件或程序集“System.Xml.ReaderWriter,版本=4.1.1.0,文化=中性” , PublicKeyToken=b03f5f7f11d50a3a' 或其依赖项之一。该系统找不到指定的文件。无法加载文件或程序集 'System.Xml.ReaderWriter, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' 或其依赖项之一。该系统找不到指定的文件。

这是一个 4.7.1 项目,测试另一个基于 EFCore 的 4.7.1 项目。

标签: visual-studiolive-unit-tests

解决方案


我收到了类似的相同错误,在“Live Unit Testing”类别的输出窗口中,我发现了以下错误:

FatalError - System.AggregateException: One or more errors occurred. ---> System.Exception: Could not load file or assembly 'System.Runtime, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.

我下载了该 nuget 包的最新版本,但它没有帮助,我基本上不得不在配置文件中强制使用 4.0.0.0 版本,这没有多大意义,因为 dll 的实际版本是 4.1。 2.0。无论如何,在那之后我停止并开始了 Live Unit Testing,现在它可以正常工作了。希望这可以帮助。

<assemblyIdentity name="System.Runtime" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" /> <bindingRedirect oldVersion="0.0.0.0-4.1.2.0" newVersion="4.0.0.0" />

推荐阅读