繁体   English   中英

带有播放列表的Visual Studio Test Explorer

[英]Visual Studio Test Explorer with playlists

这可能与问题有关: 视觉工作室中单元测试的动态播放列表

我希望能够拥有一个或多个测试播放列表,而不是没有将每个新测试添加到某个播放列表。

我目前有一个包含所有单元测试的播放列表,但是将来我希望有一个由自动集成测试组成的播放列表,应该在提交到TFS之前运行,但不是每次应用程序构建时都运行。

有没有办法做到这一点?

IM不知道类型的,你可以在TFS使用设置的,因为我不是使用TFS,但我知道这是可能使用两者的NUnitMSTest的 分类

使用NUnit解决方案

使用NUnit,您可以使用Category -Attribute标记单个测试甚至整个灯具:

namespace NUnit.Tests
{
  using System;
  using NUnit.Framework;

  [TestFixture]
  [Category("IntegrationTest")]
  public class IntegrationTests
  {
    // ...
  }
}

要么

namespace NUnit.Tests
{
  using System;
  using NUnit.Framework;

  [TestFixture]
  public class IntegrationTests
  {
    [Test]
    [Category("IntegrationTest")]
    public void AnotherIntegrationTest()
    { 
      // ...
    }
  }
}

并使用nunit-console.exe运行那些:

nunit-console.exe myTests.dll /include:IntegrationTest

使用MSTest解决方案

MSTest的解决方案非常相似:

namespace MSTest.Tests
{
    [TestClass]
    public class IntegrationTests
    {
        [TestMethod]
        [TestCategory("IntegrationTests")
        public void AnotherIntegrationTest()
        {
        }
    }
}

但是在这里你必须用该属性标记所有测试,它不能用于装饰整个类。

然后,与NUnit一样,只在IntegrationTests -category中执行这些测试:

使用VSTest.Console.exe

Vstest.console.exe myTests.dll /TestCaseFilter:TestCategory=IntegrationTests

使用MSTest.exe

mstest /testcontainer:myTests.dll /category:"IntegrationTests"

编辑

您还可以使用VS的TestExplorer执行某些测试类别。

在此输入图像描述

如上图所示,您可以在TestExplorer的左上角选择一个类别。 选择Trait并仅执行您想要的catgegory。

有关更多信息,请参阅MSDN

暂无
暂无

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

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