How to read test run settings parameter value in specflow tests?

我怕爱的太早我们不能终老 提交于 2019-12-02 07:30:16

As they are on the TestContext, you need the instance of it.

You can get it via DI:

[When(@"I do something")]
public void WhenIDoSomething()
{
    var textContext = ScenarioContext.Current.ScenarioContainer.Resolve<Microsoft.VisualStudio.TestTools.UnitTesting.TestContext>();
}

Complete example: https://github.com/techtalk/SpecFlow/blob/master/Tests/TechTalk.SpecFlow.Specs/Features/MsTestProvider.feature#L43

But be aware, that it currently doesn't work in a BeforeScenario hook (https://github.com/techtalk/SpecFlow/issues/936)

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!