6

私のキュウリはステップ定義を見つけられません。ファイル構造 (Rails ルート内の specs フォルダーのみ) は次のようになります。

-> specs
   -> features
      -> main_structure.feature
      -> step_definitions
         -> main_structure_steps.rb

これは main_structure.feature です。

Feature: Main structure
  Scenario: Viewing the Structure page
    When I am on the structure page

そして、これは main_structure_steps.rb です:

When(/^I am on the structure page$/) do
  visit '/'
end

ここで、次のように cucumber コマンドを実行します。

→ cucumber spec/features -r features 

私はこの出力を得る:

Using the default profile...
Feature: Main structure

  Scenario: Viewing the Structure page # spec/features/main_structure.feature:2
    When I am on the structure page    # spec/features/main_structure.feature:3
      Undefined step: "I am on the structure page" (Cucumber::Undefined)
      spec/features/main_structure.feature:3:in `When I am on the structure page'

1 scenario (1 undefined)
1 step (1 undefined)
0m0.229s

You can implement step definitions for undefined steps with these snippets:

When(/^I am on the structure page$/) do
  pending # express the regexp above with the code you wish you had
end

/Users/rudolf/.rvm/gems/ruby-2.0.0-p247@global/gems/minitest-4.7.5/lib/minitest/unit.rb:1037:in `block in process_args': invalid option: -r (OptionParser::InvalidOption)
    from /Users/rudolf/.rvm/gems/ruby-2.0.0-p247@global/gems/minitest-4.7.5/lib/minitest/unit.rb:1016:in `new'
    from /Users/rudolf/.rvm/gems/ruby-2.0.0-p247@global/gems/minitest-4.7.5/lib/minitest/unit.rb:1016:in `process_args'
    from /Users/rudolf/.rvm/gems/ruby-2.0.0-p247@global/gems/minitest-4.7.5/lib/minitest/unit.rb:1066:in `_run'
    from /Users/rudolf/.rvm/gems/ruby-2.0.0-p247@global/gems/minitest-4.7.5/lib/minitest/unit.rb:1059:in `run'
    from /Users/rudolf/.rvm/gems/ruby-2.0.0-p247@global/gems/minitest-4.7.5/lib/minitest/unit.rb:795:in `block in autorun'

RubyMine でテストを実行すると表示されないエラー メッセージも下部にあります。ただし、どちらの場合も、ステップ定義は見つかりません。これは Rubymine の出力です。

Testing started at 21:29 ...


You can implement step definitions for undefined steps with these snippets:

When(/^I am on the structure page$/) do
  pending # express the regexp above with the code you wish you had
end
1 scenario (1 undefined)
1 step (1 undefined)
0m0.001s

Process finished with exit code 0

追加情報が必要な場合は教えてください。

4

4 に答える 4

1

私の質問に似ています:キュウリテストが奇妙な方法で動作する

次のスニペットを使用して、未定義のステップのステップ定義を実装できます。

When(/^I am on the structure page$/) do
  pending # express the regexp above with the code you wish you had
end

エラーが言っているように。上記のコードを web_steps.rb に入れてから、pending # express the regexp above with the code you wish you had必要なコードに置き換えます

于 2013-09-12T19:44:54.040 に答える
0

Java でも同様の問題がありました。その理由は、NetBeans IDE に 2 つの Cucumber プラグインがインストールされていたためです。Cetriolo を離れ、Cucumber Features を削除すると、テストが機能し始めました

于 2013-11-19T21:19:02.843 に答える