Skipping Feature - SpecFlow C#

耗尽温柔 提交于 2020-02-06 10:18:50

问题


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

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