2016-06-14 4 views
1

私は、次のしているステップの定義(ちょうど私の問題を説明するために):私の機能ファイルでCucumberで「Undefined dynamic step」を取得するのはなぜですか?

When(/^the calculator is run$/) do 
    step %{When xxx the calculator is run xxx} 
end 

When(/^xxx the calculator is run xxx$/) do 
    @output = `ruby calc.rb #{@input}` 
    raise('Command failed!') unless $?.success? 
end 

を、私は呼び出すとき:

Undefined dynamic step: "When xxx the calculator is run xxx" (Cucumber::UndefinedDynamicStep) 
./features/step_definitions/calculator_steps_when.rb:2:in `/^the calculator is run$/' 
features/adding.feature:11:in `When the calculator is run' 
features/adding.feature:6:in `When the calculator is run' 

When the calculator is run 

を私はエラーメッセージが表示されました

これはうまくいくはずです。最初は私は別のファイルにステップを持ち、includeディレクティブをいくつか用意しなければならなかったかもしれないと思ったが、今はステップが同じファイルにあっても起こる。私は何が欠けていますか?この行で

答えて

6

ありがとう:

step %{When xxx the calculator is run xxx} 

"は" 削除し、それが正常に動作するはずです。

これはcucumber docsで確認できます。 「step」の例では、「When」という単語は含まれていません。

+3

はい、ありがとうございます。私はまた、「ステップ」を「ステップ」に変更してもそれが機能することに気付きました。 **演算子が実行されているxxxです** **または**ステップ "xxx計算が実行されていますxxx" **または** steps%{xxxは計算者が実行されたときxxx} **すべての作業、私が使ったものはそうではありません。 –

+0

ありがとうございます - 動的なテーブルステップに 'steps'を使用すると、' When/And/Then'プレフィックスが必要です。 – kross

関連する問題