问题
I'm looking to intercept a test using the [BeforeFeature] SpecFlow Hook and ignore the entire feature file.
private static string FeatureName = FeatureContext.Current.FeatureInfo.Title;
[BeforeFeature]
public static void BeforeFeature()
{
Console.WriteLine("Before feature");
if (TestFilter.ShouldBeIgnored(FeatureName))
{
// Ignore Feature if it matches TestFilter Requirements
}
}
回答1:
If you are using Specflow + Nunit, you can call
Assert.Ignore("ignore message here");
This will cause the individual tests to be ignored, if their feature is ran. However, this may require you to use a BeforeScenario hook instead of a BeforeFeature hook.
Because BeforeScenario has access to the feature info, this should not be an issue.
回答2:
Did you look into @ignore tag? You can skip features or scenarios. link
来源:https://stackoverflow.com/questions/50135126/skipping-feature-specflow-c-sharp