-
Notifications
You must be signed in to change notification settings - Fork 0
Bindings
The Gherkin feature files are closer to free-text than to code – they cannot be executed as they are. The automation that connects the specification to the application interface has to be developed first. This automation is also called binding in general. There are several kinds of bindings in SpecFlow.
The most important one is the step definition that automates the scenario at step-level. This means that instead of providing the automation for the entire scenario, this has to be done for each different step. The benefit of this model is that the step definitions can be reused in other scenarios, so it is possible to construct further scenarios partly from existing steps with less (or no) automation effort. See Step Definitions for details.
SpecFlow allows three additional advanced binding techniques.
-
The hooks can be used to perform additional automation logic on specific events, like before the execution of a scenario.
-
The step argument transformations can be used to apply a conversion step for the arguments of the step definitions. The step argument transformation is a method that provides a conversion from text (specified by a regular expression) to an arbitrary .NET type.
-
With scoped bindings, one can restrict the applicability of a step definition or hook. The restriction can be defined as scope rules. Each scope rule can restrict for feature title, scenario title or tags. With scoped step bindings it is possible to provide different automation logic for the same step depending on where it was used.
In many cases the different bindings have to exchange data during execution. See Sharing Data between Bindings for details about this.