Benefits for Developers

Simple, Modular, and Maintainable Code

SpecFlow allows you to separate test automation from specifications and provides additional tools to structure your code.

Step Definitions

Bind easy to read Gherkin specifications with .NET

Step definitions provide the connection between Gherkin feature specifications and application interfaces for test automation.

Step Definitions
When I search for books by the phrase 'Domain'
Step definition for this step:
[When(@"I search for books by the phrase '(.*)'"]
public void WhenIPerformASimpleSearchOn( string searchTerm) {
var controller = new CatalogController();
actionResult = controller.search(searchTerm);
}

Navigation to Step Definitions

Quick navigation to step definitions within your IDE

Don’t waste your time searching for the correct definition across your binding classes, just right-click and jump to the relevant code.

Navigation within IDE
GIVENWHENTHENGo to DefinitionCopyRun to Cursor

Hooks (Event Bindings):

Additional automation logic at specific events

Hooks (event bindings) can be used to perform additional automation logic at specific times, such as any setup required prior to executing a scenario.

Hooks
Clean the test database before scenario:
[BeforeScenario(Order = 0)]
public void CleanDatabase() {
// we nenn to run this first...
}

Context Injection

Instantiate & inject class instances for scenarios

SpecFlow supports a dependency injection framework that is able to instantiate and inject context for scenarios. This allows you to group the shared state in context classes, and inject them into every binding class that needs access to that shared state.

Context Injection
Class Bindings 1Set Person.FirstnameSet Person.LastnameClass Bindings 2Get Person.FirstnameGet Person.LastnameClass PersonFirstnameLastname

… curious to try it out?

Start using SpecFlow now

Boost your productivity

Next