MSTest:由于未加载任何测试或禁用了所选测试,因此未运行任何测试 [英] MSTest: No tests are run because no tests are loaded or the selected tests are disabled

查看:311
本文介绍了MSTest:由于未加载任何测试或禁用了所选测试,因此未运行任何测试的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个具有以下结构的c#解决方案:

I have a c# solution with the following structure:

mySolution
  myProject
  myProject.MSTests
    References
      Microsoft.VisualStudio.QualityTools.UnitTestFramework
    sutMSTests.cs

sutMSTests.cs:

[TestClass()] 
public class sutMSTests
{
    [TestMethod]
    public void MyTest0()
    {
        Microsoft.VisualStudio.TestTools.UnitTesting.Assert.AreEqual(4, 2 + 2);
    } 
}

当我尝试通过测试",运行",解决方案中的所有测试"运行测试时,在VS2008状态行上显示以下内容:

When I try to run the tests via Test, Run, All Tests In Solution, I get the following on the VS2008 status line:

由于未加载任何测试或禁用了所选测试,因此未运行任何测试.

No tests are run because no tests are loaded or the selected tests are disabled.

测试,Windows,测试视图未显示测试.

Test, Windows, Test View shows no tests.

注意:我手动创建了测试(适用于xUnit.net),而不是使用Microsoft的向导.

Note: I created the tests manually (works for xUnit.net) instead of using Microsoft's wizards.

我已经将自己手动创建的MSTest安装程序与使用向导生成的另一个测试进行了比较,并且 它们看上去很相似 .

I've compared my hand created MSTest setup to the setup another test that I generated using the wizard and they appear to be sufficiently similar.

问题:上述错误消息最可能的原因是什么?

Question: What are the most likely causes of the error message above?

编辑2010-02-25:更多信息:
我右键单击 Solution Items 文件夹,然后选择添加",新建项目",键入测试项目",测试文档:: Visual Studio测试项目"模板.

Edit 2010-02-25: More information:
I right clicked the Solution Items folder, and choose Add, New Project, type Test Projects,Test Documents::Visual Studio Test Project template.

检测到并通过了新项目的默认不执行测试"TestMethod1".
但是,我的测试没有显示...因此,我将测试方法复制并粘贴到默认的测试测试项目"TestProject1"中.

The new project's default do nothing test "TestMethod1" was detected and passed.
However, my test did not show up ... so I copied and pasted my test method into the default test test project "TestProject1".

在"TestProject"中检测到我的测试,但未在其原始位置进行测试.

My test was detected in "TestProject" BUT not in its original location.

我将"TestProject1"的文件,组织和设置与我手工创建的测试项目进行了仔细比较.

I closely compared the files, organization, and settings of "TestProject1" with my hand created test project.

这时,我正在猜测,某些设置是由Visual Studio Test Project模板进行的,这些设置不容易被检测到.

At this point, I am guessing that some setting gets made by the Visual Studio Test Project template that is not easily detectable.

imo,手动创建测试项目应该与使用Visual Studio测试项目模板创建项目一样容易.

imo, it should be just as easy to create a test project by hand as it is to create one with the Visual Studio Test Project template.

请注意:我并不是说我反对使用Visual Studio测试项目模板;对我来说,我想了解幕后的原因,因为这使我成为更好的程序员.

please note: I'm not saying that I'm against using the Visual Studio Test Project template; for me, I like to understand what's behind the curtain since this makes me imho a much better programmer.

推荐答案

另一种面向Google员工的问题-原来这是我的问题,令人尴尬的是我.确保将您的测试项目设置为使用您正在使用的任何解决方案配置进行构建.如果没有构建测试程序集,VS将无法在不存在的程序集中找到任何测试,并且您将把头撞在墙上一会儿:-)

Another one for the googlers - this one turned out to be my problem, and it's embarrassingly boneheaded of me. Make sure that your test project is set to build in whatever solution configuration you're using. If the test assembly isn't being built, VS won't be able to find any tests in the non-existent assembly, and you'll bang your head against the wall for a while :-)

这篇关于MSTest:由于未加载任何测试或禁用了所选测试,因此未运行任何测试的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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