2017-04-13 58 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 
    } 
});