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?
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/).
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With