Skip tagged scenarios in SpecFlow with Xunit
How to skip scenarios with a certain tag from executing
First apply a tag of your choosing to flag scenarios that are still not ready for running:
1
Feature: Skipping scenarios by tag
2
3
@Draft
4
Scenario: This is not ready yet
5
Given Something not done yet
6
Then It should not fail the CI build (yet)
Copied!
Now in the [Binding] class for any of the steps in the scenario, create a constructor that receives the ScenarioContext as follows:
1
public Steps(ScenarioContext context)
2
{
3
Skip.If(context.ScenarioInfo.Tags.Contains("Draft"));
4
}
Copied!
That's it. Turns out that the generated test for a scenario is annotated with [SkippableFact] so you can just skip from anywhere during the test run. From SkippableFact package.
Last modified 1mo ago
Copy link