简体   繁体   English

Visual Studio 2012无法找到我的测试

[英]Visual Studio 2012 unable to find my tests

I have added a "Unit Test Library" project to my solution containing a simple test class: 我在我的解决方案中添加了一个“单元测试库”项目,其中包含一个简单的测试类:

namespace Metro_test
{
    [TestClass]
    public class UnitTest1
    {
        [TestMethod]
        public void TestMethod1()
        {
            Assert.Equals(0, 1);
        }
    }
}

But I am unable to make the test show up in the text explorer window. 但我无法在文本浏览器窗口中显示测试。 I have tried cleaning/rebuilding the solution, removing/re-adding references to MSTest and editing the .csproj file to make sure the project is marked as a test-project. 我已经尝试清理/重建解决方案,删除/重新添加对MSTest的引用并编辑.csproj文件以确保项目被标记为测试项目。

The whole solution is under source control and my colleague (working with the same code) is having no problem running the test. 整个解决方案都在源代码管理下,我的同事(使用相同的代码)运行测试没有问题。

Any ideas? 有任何想法吗?

Try adding a reference to Microsoft.VisualStudio.QualityTools.UnitTestFramework, which can be found in C:\\Program Files (x86)\\Microsoft Visual Studio 11.0\\Common7\\IDE\\PublicAssemblies 尝试添加对Microsoft.VisualStudio.QualityTools.UnitTestFramework的引用,该引用可以在C:\\ Program Files(x86)\\ Microsoft Visual Studio 11.0 \\ Common7 \\ IDE \\ PublicAssemblies中找到

Then also make sure that you are using the assemblies that you added reference to. 然后还要确保使用您添加引用的程序集。

using Microsoft.VisualStudio.TestTools.UnitTesting;

and remove the old 并删除旧的

using Microsoft.VisualStudio.TestPlatform.UnitTestFramework;

EDIT 编辑

You could also just update your visual studio to update 3, which should solve this problem 你也可以只更新你的visual studio来更新3,这应该可以解决这个问题

I got into same issue when upgrading solution from VS 2010 to 2012. All tests disapeared. 当我将解决方案从VS 2010升级到2012时,我遇到了同样的问题。所有测试都没有消失。 I got over this by deleting the old (VS2010) solution file. 我通过删除旧的(VS2010)解决方案文件来解决这个问题。 Then, I created new one using VS2012 and added all the projects to the new solution. 然后,我使用VS2012创建了新的项目,并将所有项目添加到新解决方案中。 After Rebuild all tests appeared in tests explorer. 重建后,所有测试都出现在测试资源管理器中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM