的Visual Studio 2013没有发现单元测试 [英] Visual Studio 2013 doesn't discover unit tests

查看:445
本文介绍了的Visual Studio 2013没有发现单元测试的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Visual Studio 2013是一个web项目,一个库项目和一个单元测试项目组成一个简单的解决方案。当我打开的解决方案,并尝试运行单元测试他们不是由Visual Studio探索。要运行测试,我试着去的菜单,并选择测试 - >运行 - >运行所有测试或打开测试浏览器窗口。通过那些方法的Visual Studio未发现在溶液中的任何测试。

首先创建一个简单的单元测试项目,并尝试运行测试时,Visual Studio知道发现的考验,我可以运行它。然后,如果我打开我的previous解决方案的Visual Studio现在发现所有的测试。我试图挽救我的解决方案,但将其关闭并重新打开,无需先创建一个单元测试项目,在Visual Studio没有找到测试了。这是一个很奇怪的行为,我不知道为什么会这样。

我习惯一个人工作在这个项目中使用的源代码控制git的集成在Visual Studio团队基础。 Visual Studio中的问题,不能发现单元测试开始时,一个新的元素来项目,当我需要重新创建通过源代码管理解决方案在线。在此之前,所有的测试总是被发现由Visual Studio。

有关创建单元测试我使用的DLL Microsoft.VisualStudio.QualityTools.UnitTestFramework。我的Visual Studio版本是:微软的Visual Studio防爆preSS 2013的Web版本12.0.30723.00更新3.我的.NET框架的版本是4.5.50938

我所有的测试都是这样的:

  [TestClass的]
公共类Service1Test
{
    [测试方法]
    公共无效的Test1()
    {
        Assert.IsTrue(真);
    }
}
 

解决方案

有些事情我发现我必须做的,不时得到测试,以正确地显示出来。

  1. 如果您的解决方案是在您需要管理员权限来读/写一个受保护的驱动,测试有时只有一部分上来。绝对VS运行以​​管理员身份在这种情况下。

  2. 如果您的解决方案是64位,确保测试>测试设置>默认处理器架构设置为64。有时,它被设置为86。它设置为64,然后重新生成。

  3. 有时候,只是重新启动Visual Studio中开了窍,因为测试浏览器将再次启动。

I have a simple solution in visual studio 2013 that is composed by one web project, one library project and one unit test project. When I open the solution and try to run the unit tests they are not discover by visual studio. To run the tests I try to go to the menu and choose Test -> Run -> Run all tests or by opening the test explorer window. By those to methods visual studio doesn’t discover any tests in the solution.

Creating first a simple unit tests project and try to run the test, visual studio know discover the test and I can run it. Then, if I open my previous solution visual studio now discovers all the tests. I try to save my solution but closing it and reopening, without creating a unit test project first, the visual studio doesn’t find the tests again. This is a very strange behave that I don’t know why this is happening.

I used to working alone in this project that was using the source control git integrated with the visual studio team foundation. The problem of visual studio not discover the unit tests start when a new element came to the project and when I need to recreate the solution through the source control online. Before this, all tests always been discovered by visual studio.

For creation the unit tests I use the dll Microsoft.VisualStudio.QualityTools.UnitTestFramework. My version of visual studio is: Microsoft Visual Studio Express 2013 for Web Version 12.0.30723.00 Update 3. My version of .net framework is 4.5.50938.

All of my tests are like this:

[TestClass] 
public class Service1Test 
{ 
    [TestMethod] 
    public void Test1() 
    {
        Assert.IsTrue(True); 
    } 
}

解决方案

Some things I've noticed I have to do from time to time to get tests to show up properly.

  1. If your solution is in a protected drive that you need administrator access to read/write, sometimes only a portion of the tests come up. Definitely run VS as administrator in that case.

  2. If your solution is 64 bit, make sure that Test > Test Settings > Default Processor Architecture is set to x64. Sometimes it gets set to x86. Set it to x64, then rebuild.

  3. Sometimes just restarting Visual Studio does the trick because the test explorer will start up again.

这篇关于的Visual Studio 2013没有发现单元测试的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆