添加“示例:”时出现Specflow自定义工具错误

时间:2016-05-11 16:27:34

标签: visual-studio-2015 specflow

我有这个规范:

Feature: Homepage
    As a webiste user
    I want to see a pretty homepage

Scenario: Homepage Display
    Given I am on an ecommerce <website>
    When I look at the content
    Then I should see a swiper

Examples: 
| Description | website             |
| Local       | localhost:9000      |
| Development | dev.mysite.com      |

但Visual Studio 2015不会构建它说:

  

自定义工具错误:(10:1):预期:#EOF,#TableRow,#DocStringSeparator,#StepLine,#TagLine,#ScenarioLine,#ScenarioOutlineLine,#Comment,#Empty,got'examples:'

如果我删除示例:就没问题。

据我所知,规范看起来是正确的语法,但我昨天才开始探索这个,所以我可能犯了一个基本的错误。我可以右键单击场景并生成步骤代码OK,这看起来都很合理。

我正在使用 NuGet

  • SpecFlow 2.0.0
  • SpecFlow.MsTest 2.0.0

以及扩展程序和更新

  • Visual Studio 2015的SpecFlow,版本2015.1.2

我用“单元测试项目”,Framework 4.5.1来创建我的项目。

我做错了什么?

1 个答案:

答案 0 :(得分:52)

示例只能与Scenario Outlines一起使用。场景概述是运行具有不同数据集的场景的方法。

如果您将Scenario更改为Scenario Outline,您的示例将有效:

Feature: Homepage
    As a webiste user
    I want to see a pretty homepage

Scenario Outline: Homepage Display
    Given I am on an ecommerce <website>
    When I look at the content
    Then I should see a swiper

Examples: 
| Description | website             |
| Local       | localhost:9000      |
| Development | dev.mysite.com      |

GitHub Cucumber页面对场景概述有一个很好的解释: https://github.com/cucumber/cucumber/wiki/Scenario-outlines

相关问题