Advanced SpecFlow: Sharing Data Between Steps with Context Injection

SpecFlow is a tool that allows the writing of business-readable tests that can then be automated in code. If you’re new to SpecFlow check out my Pluralsight course to get up to speed before looking at these more advanced topics.

Individual step definitions that represent the natural language scenarios are separate methods that get executed. Often we need to pass data between these steps. The simplest approaches to get started with are to use simple fields in the class containing the steps or to use the Scenario Context. An alternative to these approaches is to use Context Injection.

For example, imagine the following scenario:

Feature: SomeFeature

Scenario: Add New Contact Name
    Given I have entered Sarah
    When I choose add
    Then the contact list should show the new contact

More...

SHARE:

Automated Acceptance Testing with SpecFlow and Gherkin Course

With my new Pluralsight course you’ll learn how to narrow the gap between the business/customer and the development team by creating business-readable, automated tests.

The course covers how to install SpecFlow in Visual Studio, the Gherkin business-readable domain specific language (DSL), and how to create code-automation from this natural language.

You can find the course on my Pluralsight author page.

You can start watching with a Pluralsight free trial.

SHARE: