[specflow] StepTransformation with table argument?

251 views
Skip to first unread message

Jonas Bandi

unread,
May 7, 2010, 4:57:15 AM5/7/10
to spec...@googlegroups.com


---------- Forwarded message ----------
From: Marcus Hammarberg <marcus.h...@avega.se>
Date: Thu, May 6, 2010 at 8:39 PM
Subject: Re: SpecFlow examples
To: Jonas Bandi <jonas...@gmail.com>


Hello Jonas, 

I downloaded the 1.3 release and started to work with immeditatly. 

I was planning on using the StepTransformation to transform a Table into a list of my enitites. But I'm not sure on how to write that. I cannot see any examples of that.

This is what I have so far:
.feature
Given the following events
| StartTime        | EndTime          | Title         | Speaker           |
| 2010-01-01 16:00 | 2010-01-01 20:00 | SpecFlow - an introduction          | Marcus Hammarberg |
| 2010-02-01 17:00 | 2010-02-01 20:00 | What is BDD?                        | Dan Narth         |
| 2010-03-01 18:00 | 2010-03-01 20:00 | NHibernate - what is it good for?   | Iyende Raheen     |
| 1994-01-01 14:00 | 1994-01-01 15:00 | The Internet - it could take off... | Bill Gatees       |

The transformation (and very plain entity):
[StepTransformation("events")]
        public IEnumerable<Event> EventListConverter(Table table)
        {
            return new List<Event>
                             {
                                 new Event(),
                                 new Event(),
                                 new Event()
                             };
        }


    public class Event
    {
    }

and the Given-step:
[Given(@"the following events")]
        public void GivenTheFollowingEvents(IEnumerable<Event> events)
        {
            ScenarioContext.Current.Pending();
        }



This gives me the error:
-> binding error: Error calling binding method 'ListEventsSteps.GivenTheFollowingEvents(IEnumerable`1)': Object of type 'TechTalk.SpecFlow.Table' cannot be converted to type 'System.Collections.Generic.IEnumerable`1[Avega.Elevator.Specs.Transformations.Event]'.


What am I doing wrong?
/Marcus 



jbandi

unread,
May 7, 2010, 5:05:35 AM5/7/10
to SpecFlow
Unfortunately step transformations with table arguments are not
supported as far as I remember.
Currently step transformations are only working on regexp-groups of
the step-description.

This would be a cool new feature though and should not be too hard to
implement for a next release.
Anybody wants to try?
Reply all
Reply to author
Forward
0 new messages