In SpecFlow how can I share data between steps/features?

前端 未结 6 707
情深已故
情深已故 2020-12-05 01:54

I have 2 features that use a common \'When\' step but have different \'Then\' steps in different classes.

How do I access, for example, the ActionResult from my MVC

6条回答
  •  无人及你
    2020-12-05 02:39

    I did not like using Scenario.Context because of the need for casting out each dictionary entry. I found another way to store and retrieve the item without the needing to cast it. However there is a trade off here because you are effectively using the type as the key access the object from the ScenarioContext dictionary. This means only one item of that type can be stored.

    TestPage testPageIn = new TestPage(_driver);
    ScenarioContext.Current.Set(testPageIn);
    var testPageOut = ScenarioContext.Current.Get();
    

提交回复
热议问题