What Is Specflow Scenariocontext

What Is Specflow 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.

What is ScenarioContext?

ScenarioContext is a static class that has a shared state during the execution of a scenario. It can be freely used as a dictionary by either storing an object of a specific type with or without specifying a string key.

What is SpecFlow FeatureContext?

SpecFlow provides access to the current test context using both FeatureContext and the more commonly used ScenarioContext. FeatureContext persists for the duration of the execution of an entire feature, whereas ScenarioContext only persists for the duration of a scenario.

Maya Lin-Takahashi
Author

Maya Lin-Takahashi

Maya is a hardware enthusiast who tests and reviews smart home devices, smartphones, wearables, and audio gear. She focuses on practical consumer value and build quality.