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

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

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

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

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


当前回答

对我来说,修复它的是升级ms测试金包

其他回答

最初,我用。net库创建了测试项目,并添加了xunit和xunit.runner.visualstudio,但这并没有帮助我运行测试用例。

后来用xunit测试项目模板创建测试项目,自动添加覆盖。收集器,Microsoft.NET。Sdk, xunit, xunit。runner.visualstudio nuget包。现在我可以运行测试用例了。

如果你正在使用NUnit而不是MSTest,那么你将需要NUnit 2测试适配器或NUnit 3测试适配器(Visual Studio≥2012/2013)。

将测试项目升级到最新的目标框架版本。

我使用的是Visual studio 2019,目标框架4.5的支持在2016年结束,跳转到4.7解决了我的问题。

已经尝试了VisualStudio 2019 Version 16.4.6和Microsoft.VisualStudio.TestTools的许多选项。UnitTesting,但是现在成功运行测试的唯一方法是在控制台调用下一个命令

dotnet test

在测试资源管理器中发现测试,但结果为“未运行”。

更新Visual Studio也无济于事。

通过运行更新到下一个包的最新版本,解决了“没有测试匹配给定的测试用例过滤器FullyQualifiedName”的问题:

Microsoft.NET.Test.Sdk
MSTest.TestAdapter
MSTest.TestFramework

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.