我希望能够从 vstest.console.exe 命令行运行每个 Specflow 功能,而不是运行该项目中的所有测试。我意识到有一个用于按类别过滤的命令行参数,但对我来说如何定义 Specflow 测试的类别并不明显。有没有办法做到这一点,或者有没有其他方法来完成分组specflow测试,通过命令行使用vstest.console运行?
最佳答案
你想要Tags 。一旦您意识到 SpecFlow 实现了 Gherkin Language,SpecFlow 就会变得更容易理解.
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/