Last Updated: February 25, 2016
· ritasker

Specflow Steps with Regex

It is possible to use Regular Expressions in the Given, When Then attributes of your step definitions. This gives the developer/tester the ability to reuse Step Definitions.

[Given(@"I have an object with the name '(.+)'")]
public void ExampleStepDefinition(string objectName)

But remember to surround the regex with brackets as Specflow with throw a parameter mismatch error.

2 Responses
Add your response

Create post!

We are currently working on this subject in the upcoming "Specflow Cookbook" and It would be great to get your impressions on the chapter dealing with Regular Expressions.

over 1 year ago ·

I have read through the chapter.
Really liked the examples, even learned something about RegEx I didn't know.
If you want any other chapters reviewing I would be happy to help.

over 1 year ago ·