Vinee
Vinee

Reputation: 402

How to add Nunit 3 testcontext to Specflow scenario

I would like to implement Nunit testcontext option in to my specflow ScenarioContext. I tried adding this line manually in the RandomName.Feature.cs file's ScenarioSetup method

testRunner.ScenarioContext.ScenarioContainer.RegisterInstanceAs<NUnit.Framework.TestContext>(TestContext);

testRunner.ScenarioContext.Add("TestContext", TestContext);

But the name test context does not exist in the current context. Any pointers on how to make use of the Nunit test context in specflow please

Upvotes: 0

Views: 938

Answers (1)

unickq
unickq

Reputation: 3333

TestContext.CurrentContext is required

testRunner.ScenarioContext.ScenarioContainer
.RegisterInstanceAs<NUnit.Framework.TestContext>(TestContext.CurrentContext);

Upvotes: 0

Related Questions