Using tags in SpecFlow

We can use tags in SpecFlow to group the scenarios. Consider below feature file.

Feature: Bank Feature File

Scenario: ATM money withdrawal scenario
	Given I have $1000 in my account 
	When I withdraw $200 from ATM
	Then my balance should be $800

Scenario: ATM money - Enter Pin
	When I enter PIN as 4141
	Then I should see the Transaction options

Scenario: ATM - Check Balance scenario
	Given I have $1000 in my account 
	When I view the balance
	Then my balance should be $1000


In this feature file, we have tagged 2 scenarios with tag – sanity and one scenario is tagged with regression. After building the solution, test explorer shows these scenarios under sanity and regression tags. This is how we can group the scenarios in SpecFlow. To execute the scenarios tagged with specific name, we can just right click on the tag name in the test explorer and click on run selected tests.

Tags in SpecFlow

Tags in SpecFlow

You may also like...