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"。


为什么?


天涯尽头无女友
浏览 70回答 1
1回答

慕哥6287543

在您的 SpecFlow 代码中,替换Scenario为Scenario Outline:Scenario Outline: Check all these numbers&nbsp; &nbsp; Given I got <cat>&nbsp; &nbsp; When I get string <string>&nbsp; &nbsp; Then I see result <result>Examples:&nbsp;&nbsp; &nbsp; | cat | string | result |&nbsp; &nbsp; | 1&nbsp; &nbsp;| a&nbsp; &nbsp; &nbsp; | 1=a&nbsp; &nbsp; |&nbsp; &nbsp; | 2&nbsp; &nbsp;| b&nbsp; &nbsp; &nbsp; | 2=b&nbsp; &nbsp; |&nbsp; &nbsp; | 3&nbsp; &nbsp;| c&nbsp; &nbsp; &nbsp; | 3=c&nbsp; &nbsp; |
打开App,查看更多内容
随时随地看视频慕课网APP