为什么specflow不作为参数传入表
本文关键字:参数 specflow 不作为 为什么 | 更新日期: 2023-09-27 18:13:57
我有以下(Gherkin)场景大纲(使用Specflow v1.9):
Scenario Outline: Add section title to report
Given I have "<section titles>" in a form:
When I edit the layout of the XX page
Then I should see the "<section titles>" as available columns for customizing the layout
When I add "<section titles>" to the list of selected columns
And save the changes
Then the "<section titles>" are added to the report
And shows a color-coded view of the total applicant score categorized as follows:
| score_min | score_max | color |
| 0 | 25 | red |
| 25 | 75 | yellow |
| 75 | 100 | green |
Examples:
| section titles |
| MyTitle1 |
| MyTitle2 |
然而,在最后一个"And"步骤定义中,表从未在参数中传递。下面是Specflow生成的代码:
[Then(@"shows a color-coded view of the total applicant score categorized as follows:")]
public void ThenShowsAColor_CodedViewOfTheTotalApplicantScoreCategorizedAsFollows()
{
//Note missing 'Table' in argument
ScenarioContext.Current.Pending();
}
然而,自动生成的特性文件的代码后面的似乎有这个表,但它不是我的步骤定义的一部分:
#line hidden
TechTalk.SpecFlow.Table table1 = new TechTalk.SpecFlow.Table(new string[] {
"score_min_percentage_equal_to",
"score_max_percentage_less_than_or_equal_to",
"color"});
table1.AddRow(new string[] {
"0",
"25",
"red"});
table1.AddRow(new string[] {
"25",
"75",
"yellow"});
table1.AddRow(new string[] {
"75",
"100",
"green"});
#line 14
testRunner.And("shows a color-coded view of the total applicant score categorized as follows:", ((string)(null)), table1, "And ");
#line 19
看起来"应该"有一个用于步骤定义的表参数,但是在生成步骤时似乎缺少了它。我错过了什么?
更新:5/13/2016:这个错误被Specflow开发者提出并解决了:https://github.com/techtalk/SpecFlow/issues/487
如果没有示例表,场景大纲本身是无用的,并且只有示例可以与场景大纲一起使用。如果我们讨论幕后,则示例中的每一行都被转换为单个场景。正如Sam建议的那样,我们必须在方法定义中手动输入参数。