SpecFlow Tables And Parameters Invalid cast from System.String to TechTalk.SpecFlow.Table

If your trying to use a parameter and a table in the one step and you get this exception

System.InvalidCastException: Invalid cast from ‘System.String’ to ‘TechTalk.SpecFlow.Table’.

Make sure your table parameter is the last one in the method like this.

        [Given(@"i have the (.*) Templates")]
        public void GivenIHaveTheTemplate(string templateType, Table table)

It can be a bit tricky to find the problem due to the exception being thrown in SpecFlow rather than your own code so the debugger wont hit it.

  1. Leave a comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: