2017-04-13 68 views
0

我想标记我BeforeFeature钩子CucumberJS - 量角器测试,使得黄瓜JS - 标记BeforeFeature

  1. 钩只运行与该标记
  2. 钩内的代码功能的文件运行前只有一次功能文件的开始,而不是在每个场景之前

例如 - 登录在BeforeFeature特定用户只对一个特征文件“abc.feature”

在cucumberjs现有方案BeforeFeature的是如下 -

this.registerHandler('BeforeFeature', function (feature) { 
     //do common action before feature file execution 
    }); 

我不知道,如果它需要标签作为参数。有没有其他方法可以在BeforeFeature级别指定标签?

回答

0
this.BeforeFeature(function(feature) { 
    feature.getTags().forEach(function (tag) { 
     if(tag.getName() === '@myTag') { 
      //do common action before feature file execution 
     } 
    }); 
}); 

OR

this.BeforeFeature(function(feature) {   
    if(feature.getName() === 'ABC') {//Gherkin file => Feature: ABC 
     //do common action before feature file execution 
    } 
});