Connecting SpecFlow features to steps. The link keeps on breaking

Go To StackoverFlow.com

0

Good morning.

I'm having a problem with SpecFlow and I can't figure out how to solve it. Would appreciate any help. So...

Lets take a simple SpecFlow feature:

Given the JoeDoe user is associated to an existing staff account with the following information
  | Field       | Value         |
  | First Name  | Joe           |
  | Last Name   | Doe           |

Which connects to the following step:

        [Given(@"the JoeDoe user is associated to an existing staff account with the following information")]
        public void GivenTheJoeDoeUserIsAssociatedToAnExistingStaffAccountWithTheFollowingInformation(Table table)
       {
        ...logic
       }

But once I change the step to accept parameters from the Feature such as the following:

        [Given(@"the (*.) user is associated to an existing staff account with the following information")]
        public void GivenTheJoeDoeUserIsAssociatedToAnExistingStaffAccountWithTheFollowingInformation(string userName, Table table)
       {
       ...logic
       }

The feature-to-step link breaks. From that point on if I press F12 ( Or go to Step Definition ) from within the featere Visual Studio tells me that there is no matching step and:

"No matching step binding found for this step! Do you want to copy the binding skeleton to clipboard ?"

And of course the test scenario doesn't run.

What's going on? I seem to be doing everything correctly.

2012-04-04 18:01
by InspiredBy


2

Have you tried:

    [Given(@"the (.*) user is associated to an existing staff account with the following information")]
    public void GivenTheJoeDoeUserIsAssociatedToAnExistingStaffAccountWithTheFollowingInformation(string userName, Table table)
   {
   ...logic
   }

It should be (.*) instead of (*.).

2012-04-04 19:04
by Justin Ko
Thank you for your reply. Sorry, it's just a typo here as I was providing the example. In my code the regex value is correct. I'll modify the OP - InspiredBy 2012-04-04 19:14
Actually I'll reverse it ack to *. here in OP...Who knows, could be useful to someone some day. But yeah, in my case it's not the problem - InspiredBy 2012-04-04 19:16
Though not the issue in my case either but this could be another solution for some one else: http://groups.google.com/group/specflow/browse_thread/thread/f66f679d34edfeb - InspiredBy 2012-04-04 19:18
Ads