2017-04-13 3 views
0
私はCucumberJSで私BeforeFeatureフックをタグ付けしたい

- 分度器のテストフックがそのタグ キュウリJS - タグ付きBeforeFeature

  • フック内のコードと機能のファイルに対してのみ実行され、このような

    1. ことは前に一度だけ実行されますすべてのシナリオの前ではなく、フィーチャファイルの開始。

    -

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

    私はそれが引数としてタグを取るかどうかわからないです - のみの機能ファイル「abc.feature」

    cucumberjsでBeforeFeatureの既存の実装は以下の通りであるためBeforeFeature内の特定のユーザーとしてログイン。 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 
        } 
    }); 
    
    関連する問題