Scenario outline with examples and step definitions

1,369 views
Skip to first unread message

András Csányi

unread,
Oct 23, 2013, 1:08:06 PM10/23/13
to spec...@googlegroups.com
Hi All,

I would like to ask some help regarding step definitions and scenario outlines.

I have this scenario outline where I check whether the necessary buttons are displayed or not on a particular field.

Scenario Outline: The grid has CRUD buttons
 Given I am on the homepage
 And I navigate to the "categories" field
 And the grid of the "categories" field is displayed
 When I check the grid buttons
 Then the grid has a button for <Function> rows function
 
 Examples: 
 | Function |
 | Add      |
 | Edit     |
 | Delete   |
 | Find     |
 | Reload   |

If I would like to use the "Generate Step definitions" function then it gives the code below as a step definition for the "Then" part:

        [Then(@"the grid has a button for Add rows function")]
        public void ThenTheGridHasAButtonForAddRowsFunction()
        {
            ScenarioContext.Current.Pending();
        }

However, the example below would be ok as far as I know.

        [Then(@"the grid has a button for ""(.*)"" rows function")]
        public void ThenTheGridHasAButtonForRows(string desiredButton)
        {
            //some code...
        }

If I have the latter and I run the scenario then I can see 5 particular tests in the "Unit test sessions..." field and I get the error message below:

Given I am on the homepage
-> done: NavigationStepDefs.GivenIAmOnTheHomepage() (0.0s)
And I navigate to the "categories" field
-> done: NavigationStepDefs.GivenINavigateToTheField("categories") (12.4s)
And the grid of the "categories" field is displayed
-> done: FieldDisplayingStepDefs.ThenTheGridOfTheFieldIsDisplayed("categories") (0.0s)
When I check the grid buttons
-> done: CheckingStepDefs.WhenICheckTheGridButtons() (0.0s)
Then the grid has a button for Reload rows function
-> No matching step definition found for the step. Use the following code to create one:
        [Then(@"the grid has a button for Reload rows function")]
        public void ThenTheGridHasAButtonForReloadRowsFunction()
        {
            ScenarioContext.Current.Pending();
        }

At the moment I do not have any idea what could be the problem, Can anybody tell me what is wrong with this code?

Thanks for any help in advance!

András

-- 
--  Csanyi Andras (Sayusi Ando)  -- http://sayusi.hu -- http://facebook.com/andras.csanyi
--  ""Trust in God and keep your gunpowder dry!" - Cromwell

Oliver Friedrich

unread,
Oct 24, 2013, 7:08:05 AM10/24/13
to spec...@googlegroups.com
You seem to be missing the quotes ("<Function>") in your feature file since your step definition explicitly expects them: [Then(@"the grid has a button for ""(.*)"" rows function")].

--


2013/10/23 András Csányi <sayus...@gmail.com>

--
You received this message because you are subscribed to the Google Groups "SpecFlow" group.
To unsubscribe from this group and stop receiving emails from it, send an email to specflow+u...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

András Csányi

unread,
Oct 25, 2013, 7:04:12 AM10/25/13
to spec...@googlegroups.com
On 24 October 2013 13:08, Oliver Friedrich <oliver.f...@gmail.com> wrote:
> You seem to be missing the quotes ("<Function>") in your feature file since
> your step definition explicitly expects them: [Then(@"the grid has a button
> for ""(.*)"" rows function")].

You are right! Thanks for the help! :)
Reply all
Reply to author
Forward
0 new messages