visual-studio - 按 Visual Studio 类别对 Specflow 测试进行分组

标签 visual-studio integration-testing specflow vstest

我希望能够从 vstest.console.exe 命令行运行每个 Specflow 功能,而不是运行该项目中的所有测试。我意识到有一个用于按类别过滤的命令行参数,但对我来说如何定义 Specflow 测试的类别并不明显。有没有办法做到这一点,或者有没有其他方法来完成分组specflow测试,通过命令行使用vstest.console运行?

最佳答案

你想要Tags 。一旦您意识到 SpecFlow 实现了 Gherkin Language,SpecFlow 就会变得更容易理解.

来自Tags documentation :

Tags are a great way to organise your features and scenarios. ... A Scenario or feature can have as many tags as you like. Just separate them with spaces ... Any tag that exists on a Feature will be inherited by Scenario, Scenario Outline or Examples.

一个简单的例子:

@posts
Feature: Blog Posts

    @comments
    Scenario: Adding a comment
        ...

    @comments
    Scenario: Deleting a comment
        ...

场景声明上方的 @foo 语法创建可以使用 MS Test 运行的类别。

之后,您可以使用 Visual Studio 中的“测试 View ” Pane 按类别筛选所有测试,或从 Visual Studio 命令行运行它们:

mstest /testcontainer:Blog.Tests.dll /category:comments

不久前我实际上有一个类似(但不重复)的问题:How do you run SpecFlow scenarios from the command line using MSTest? 。这可能是一本很好的读物。

关于visual-studio - 按 Visual Studio 类别对 Specflow 测试进行分组,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24828040/

相关文章:

xslt - SpecFlow 的自定义报告

c# - 找不到 Dumpbin.exe

visual-studio - 如何在 Visual Studio 中添加高优先级 TODO 注释?

java - 如何通过 WireMock 代理(几乎)所有请求?

java - Spring集成测试-配置中的事务声明似乎破坏了测试

c# - 无法在 Framework 4.6.1 中创建 Specflow 文件

tfs - 让 pickles 导入测试结果的 MSBuild 参数导致非法路径错误

visual-studio - 如何从 Visual Studio 2008 解决方案导出类列表

Visual Studio 2010 中的 C++ 隐式类型转换

asp.net-mvc - 使用数据对 ASP.NET MVC 进行单元测试