SpecFlow与示例字段不匹配

时间:2019-03-07 15:49:43

标签: c# .net-core bdd specflow

我有一个场景:

Scenario: Check all these numbers
    Given I got <cat>
    When I get string <string>
    Then I see result <result>
Examples: 
    | cat | string | result |
    | 1   | a      | 1=a    |
    | 2   | b      | 2=b    |
    | 3   | c      | 3=c    |

此步骤定义:

[Given(@"I got (.*)")]
public void Igot(string cat)
{
    // will do stuff here
}

方法cat中的Igot()参数正在接收值"<cat>",而不是字符串值"1"

为什么?

1 个答案:

答案 0 :(得分:3)

在您的SpecFlow代码中,将Scenario替换为Scenario Outline

Scenario Outline: Check all these numbers
    Given I got <cat>
    When I get string <string>
    Then I see result <result>
Examples: 
    | cat | string | result |
    | 1   | a      | 1=a    |
    | 2   | b      | 2=b    |
    | 3   | c      | 3=c    |