我目前正在开发一个有32个单元测试的解决方案。我一直在使用resharper测试运行器-它工作得很好。所有测试都在运行,所有测试都显示正确的测试结果。

但是,在使用Visual Studio测试资源管理器时,测试未运行。

测试资源管理器正在显示所有单元测试,但一旦单击“全部运行”,所有测试都将变成灰色,并且不显示测试运行的结果:

所有测试类都是公共的 所有测试类都声明了[TestClass]属性 所有测试方法都使用[TestMethod]属性 生产力代码和测试项目都是针对。net 3.5的。 我已经尝试清洁构建我的解决方案,和/或删除所有obj, bin,调试和发布文件夹

我很感激任何能解释这种行为的提示。


当前回答

我添加了<PackageReference Include="NUnit3TestAdapter" Version="3.16.1"> <PrivateAssets>all</PrivateAssets> <IncludeAssets>runtime;构建;本机;contentfiles;分析程序;buildtransitive < / IncludeAssets > < / PackageReference >

在我的测试中。csproj文件

其他回答

Clean-Rebuild解决方案对我很有效。

如果你正在使用NUnit,请确保添加nuget包

注意,VSIX测试适配器在VS 2019中已弃用,我们建议您使用适配器的nuget版本。这来自https://marketplace.visualstudio.com/items?itemName=NUnitDevelopers.NUnit3TestAdapter

I found that in the project it was not referencing the Microsoft.VisualStudio.QualityTools.UnitTestFramework assembly. Instead, it was referencing Microsoft.VisualStudio.TestPlatform.TestFramework and Microsoft.VisualStudio.TestPlatform.TestFramework.Extensions. When I removed those two references and added the reference to the Microsoft.VisualStudio.QualityTools.UnitTestFramework assembly the tests that were previously marked with the blue exclamation point suddenly became active and started working.

我也遇到过同样的问题,但当我在实际的桌面上创建一个工作副本时,我的问题得到了解决。对我来说,这个问题是因为项目文件夹位于网络驱动器上,由于某种原因,依赖项无法在网络驱动器上加载。希望这能帮助到一些人。

我解决的问题与这里的任何解决方案都完全不同:

我的每个测试都调用了一个函数,这个函数反过来调用自己,这意味着它不会终止:

public GoogleIntent CreateIntent(BotPath botpath)
{
    return CreateIntent(botpath);
}