我有一些测试是使用Microsoft.VisualStudio.TestTools内置的。单元测试,但不能让它们运行。

我使用visual studio 2012终极版。

我有两个项目的解决方案;一个有测试,使用Microsoft.VisualStudio.TestTools。UnitTesting, [TestClass]在类之前,[TestMethod]在测试方法之前,并参考Microsoft.VisualStudio.QualityTools.UnitTestFramework(版本10.0.0.0,运行时版本v2.0.50727)。我已经尝试过。net框架3.5,4和4.5其他人给出了一个重定向错误。

我已经尝试构建解决方案和项目。测试资源管理器显示“构建解决方案以发现所有可用的测试”。单击“全部运行”可在解决方案中构建、发现和运行所有测试。

问题是:如何让visual studio找到测试?


我也试过遵循这个:http://msdn.microsoft.com/en-US/library/ms379625%28v=VS.80%29.aspx但没有成功:当我被要求右键单击并选择创建测试时,我被困在了开始的部分。没有创建测试。


我有这个测试(它编译,但不显示在测试资源管理器):

using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace tests {
    [TestClass]
    public class SimpleTest {
        [TestMethod]
        public void Test() {
            Assert.AreEqual("a","a", "same");
        }
    }
}

我现在发现(见下面删除的答案),这是因为它在一个共享驱动器上,但我还不知道如何绕过它。(可能是关于安全设置的问题)。


当前回答

我得到的错误:“初始化客户端代理失败:无法连接到vste .discoveryengine.exe。”

尝试以管理员身份运行Visual Studio。这对我很管用。

有另一篇Stack Overflow文章讨论了这个错误,同样的解决方案也适用于他们。问题是为什么这样做有效。

其他回答

我在VS2013终极版的网络共享中打开解决方案时遇到了同样的问题。

我通过开机来解决这个问题

控制面板-> Internet选项->“安全”选项卡->单击“本地intranet”,单击站点并确保勾选“自动检测intranet网络”。

I found the best way to troubleshoot this issue is to create a .proj msbuild file and add your unit test projects which you hare having an issue into this file and execute the tests using the command line version of mstest. I found a small configuration issue in my app.config which only appeared when running the tests from mstest - otherwise the test project built just fine. Also you will find any indirect reference issues with this method as well. Once you can run the Unit test from the command line using mstest you can then do a clean solution, rebuild solution and your test should be discovered properly.

加上我的答案,因为这是谷歌上的顶部结果。

我使用Visual Studio 2015和(不知不觉-我只是运行安装包NUnit)安装NUnit3包NuGet到我的测试项目。我已经安装了NUnit测试适配器扩展,我的测试仍然没有显示。

通过工具>扩展和更新安装NUnit3测试适配器为我解决了这个问题。

我有时也会有同样的症状。

我所做的是: 1. 关闭测试资源管理器窗口 2. 清洗溶液 3.重新构建解决方案 4. 从Test -> Windows ->测试资源管理器重新启动测试资源管理器窗口。

我在测试资源管理器窗口中得到了我的测试。

我知道这是一个老问题,但在Visual Studio 2015中,我遇到了新创建的测试类无法识别的问题。尝试一切。最终的问题是这个类没有“包含在项目中”。我只是在重新启动Visual Studio时才发现这一点,并注意到我的测试类不在那里。在显示隐藏文件时,我发现它以及我编写的其他类都不包括在内。希望这能有所帮助