1
votes

I have the following (Gherkin) scenario outline (using 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       |

However, in the last "And" step definition, the table is never passed in the argument. Here's the code that is generated by 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();
}

However, the autogenerated feature file's code-behind seems to have this table, but it's not part of my step definition:

#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

It looks like there "should" be a table argument for the step definition, but it seems to be missing when the steps are generated. What am I missing?

UPDATE: 5/13/2016: The bug was raised and resolved by the Specflow devs: https://github.com/techtalk/SpecFlow/issues/487

1
Maybe you generated the code without a table, an incorrect table or an empty line between the step and the table. What happens if you delete the step code and regenerate the step? An easy work around would be manually adding a Table applicantScoreTable argument to the method signature.AutomatedChaos
yeah I can repro this and there doesn't seem to be a simple workaround. Please log a defect at the github issues page. Please include either a link to this question, or (better) include this scenario outline in the defect reportSam Holder
I agree with Sam, it is reproducible whenever a Scenario Outline is used and there is an Examples table present. The location of the step with a normal table doesn't matter, it does not have to be the last step before the Examples table and can be a Given, When or Then step or And/But placeholder.AutomatedChaos
@SamHolder - I raised the issue: github.com/techtalk/SpecFlow/issues/487. For now it seems we just have to manually type out the missing parameter.PhD
I have just opened a pull request which fixes this issueSam Holder

1 Answers

-1
votes

The scenario outline itself is useless without a table of Examples and only Examples can be used with Scenario Outline. If we talk about Behind the scenes, Each row in an Examples is converted into a single scenario. As Sam suggested we had to manually enter the arguments in a method definition.