Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get scenario name and parameters? specflow

In this question scenario.getName was used to the name of the scenario. I need to get the name in addition to the parameters. For example if scenario is :

Scenario Outline: name of scenario
Given I am on the proper page
When I apply <filter>  with <params>
And I click filter
Then the data should be filtered
Examples:
| filter    | params      |
| Date      | Today       |
| Name      | Some Name   |

I want to get nameOfScenario(Date,Today).

Also I am using C# not java

UPDATE

I know when I open test cases with NUnit they show as nameOfScenario(Date,Today). Any ideas how Nunit does it?

like image 794
mosaad Avatar asked Feb 26 '15 12:02

mosaad


People also ask

How do you get a tag name in SpecFlow?

You can get a list of tags of the Scenario in the ScenarioContext. You can get the actual ScenarioContext via Context-Injection (http://specflow.org/documentation/Context-Injection/) or via ScenarioContext. Current (http://specflow.org/documentation/ScenarioContext/).

What is scenario context in SpecFlow?

ScenarioContext helps you store values in a dictionary between steps. This helps you to organize your step definitions better than using private variables in step definition classes. There are some type-safe extension methods that help you to manage the contents of the dictionary in a safer way.


1 Answers

Feel free to use TestContext.CurrentContext.Test.Name -- it will definitely help you to get exact parametrized Scenario name.

Specflow doesn't leads with parameters at runtime, it is NUnit (or other unit test framework) responsibility.

At the least you can explore TestContext.CurrentContext.Test properties for obtaining parameters list.

like image 103
Kot Matroskin Avatar answered Oct 20 '22 12:10

Kot Matroskin