跳过功能-SpecFlow C# [英] Skipping Feature - SpecFlow C#

查看:67
本文介绍了跳过功能-SpecFlow C#的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我打算使用[BeforeFeature] SpecFlow挂钩拦截测试,并忽略整个功能文件.

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
    }
}

推荐答案

如果您使用的是Specflow + Nunit,则可以致电

If you are using Specflow + Nunit, you can call

Assert.Ignore("ignore message here");

如果已运行单个测试的功能,则将忽略这些测试.但是,这可能需要您使用BeforeScenario挂钩而不是BeforeFeature挂钩.

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.

因为BeforeScenario可以访问功能信息,所以这应该不是问题.

Because BeforeScenario has access to the feature info, this should not be an issue.

这篇关于跳过功能-SpecFlow C#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆