tags:

views:

64

answers:

1

I am writing features with the same verbiage for some scenarios.

Feature: User Management
Scenario: Edit an existing user's details
Given a user exists

and

Feature: Group Management
Scenario: Add a user to a group's membership
Given a user exists
And a group exists

In SpecFlow is there a good way to define what step each feature calls? Am I going about this the wrong way with my scenario writing? Should I just bite the bullet and change my given statements to denote what feature they apply to? I'm new to BDD and SpecFlow so any help is appreciated.

A: 

The Gherkin format (that the tools in the Cucumber-family, like SpecFlow uses) does not have any structure for sharing steps between features (inside a feature, you can use backgrounds).

The meaning behind this is that the features should be self-describing and complete in their own. With using the Background section, you can avoid having too long scenarios, but still having all information together in the file. You have to repeat the shared steps for each feature, though.

As an alternative, you can also create event bindings (that is like "hooks" in cucumber), where you can implement some shard logic. But this shared logic has to be implemented in .NET then.

Gaspar Nagy
I think the background is exactly what I am looking for here. Thanks!
jpmcclung