如何在behat中排除特定标签的beforeFeature

时间:2015-09-14 10:18:06

标签: behat gherkin

我有一个带特定标签的behat功能,我有两个beforeFeature功能。其中一个针对每个方案运行,其中一个仅针对特定标记方案运行。问题是没有标记的beforeFeature也会在具有标记的那些功能之前运行。我想使这个beforeFeature不能在具有特定标签的那些功能上运行。 例如,我有以下功能:

@taggedFeature
Feature: This feature runs tagged beforeFeature

在我的FeatureContect中,我有以下beforeFeature函数

/** @BeforeFeature */
public static function beforeFeatureDefault()
{ 
 // Do something
}

 /** @BeforeFeature @taggedFeature*/
public static function beforeFeatureTagged()
{ 
 // Do something
}

我想要的是在我的标记功能之前不运行beforeFeatureDefault()函数。

1 个答案:

答案 0 :(得分:1)

您可以使用~排除标记的功能:

/** @BeforeFeature ~@taggedFeature */
public static function beforeFeatureDefault() {
     echo 'beforeFeatureDefault()';
}

/** @BeforeFeature @taggedFeature */
public static function beforeFeatureTagged() {
     echo 'beforeFeatureTagged()';
}