Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Reusing SpecFlow Scenarios

Tags:

.net

bdd

specflow

I've started using SpecFlow and wondering it wold be possible to reuse scenarios between specs

Basically my idea is this (i might be fundamentally wrong :) )

I have one feature written to validate the navigations.

Feature: Navigation

I should be able to navigate to all the pages i'm authorized to

Scenario: Navigate to Boo

Given I enter proper values in Foo
When I enter Go
Then I should be taken to Boo**

And then I have another spec that would validate the operational side of the Boo

Feature: Validate if Boo is working ok

So in here i basically need to navigate to the Boo screen first. I was thinking if I can reuse the Scenario: Navigate to Boo scenario written in Navigation

Is this possible? Else, what is the best way to go around it?

/BB

like image 936
Illuminati Avatar asked Jul 11 '11 08:07

Illuminati


1 Answers

You have two options here:

  1. Create a class which has shared steps, common to many scenarios. In your case, this class would contain the step "When I navigate to Boo". This then would be available to other features.

  2. You can have to more then one step with the exact same name/text, but you can use a ScopedStepBinding to make sure the correct version of that step is called for a feature. So you could have "When I navigate to Boo" appearing in more then one feature file, but by using a step scoping, you can control which code is run for a feature file.

like image 52
Jason Evans Avatar answered Dec 08 '22 17:12

Jason Evans