跳过功能 - SpecFlow C#
Skipping Feature - SpecFlow C#
我正在寻找使用 [BeforeFeature] SpecFlow Hook 拦截测试并忽略整个功能文件。
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,你可以调用
Assert.Ignore("ignore message here");
这将导致个别测试被忽略,如果它们的特征是 运行。
但是,这可能需要您使用 BeforeScenario 挂钩而不是 BeforeFeature 挂钩。
因为 BeforeScenario 可以访问功能信息,所以这应该不是问题。
您是否查看过@ignore 标记?您可以跳过功能或场景。
link
我正在寻找使用 [BeforeFeature] SpecFlow Hook 拦截测试并忽略整个功能文件。
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,你可以调用
Assert.Ignore("ignore message here");
这将导致个别测试被忽略,如果它们的特征是 运行。 但是,这可能需要您使用 BeforeScenario 挂钩而不是 BeforeFeature 挂钩。
因为 BeforeScenario 可以访问功能信息,所以这应该不是问题。
您是否查看过@ignore 标记?您可以跳过功能或场景。 link