15
I have several feature files with some scenarios. I need to ignore several scenarios, or features, marked with some @tag depending on some condition. I have read specflow documentation but didn't find there something that can be useful for my solution. I want to use something like
[BeforeScenario("sometag")]
public static void BeforeScenario()
{
if(IgnoreTests)
{
// This is the hot spot
Scenario.DoSomethingToIgnoreScenarioIfConditionButRunScenarioIfConditionFalse();
}
}
Also I tried dynamically add or remove tags
[BeforeScenario("sometag")]
public static void BeforeScenario()
{
if(IgnoreTests)
{
ScenarioContext.Current.ScenarioInfo.Tags.ToList().Add("ignore");
}
}
but it didn't work. Maybe is there some other way to dynamically add or remove tags? Or some methods in ScenarioContext class which will ignore current scenario?