簡體   English   中英

黃瓜未識別步驟定義

[英]Cucumber not identifying steps definition

我已經寫了一個功能和一個步驟定義。 但是,黃瓜無法識別步驟定義。

my_first.feature

Feature:
  As an iOS developer
  I want to have a sample feature file
  So I can see what my next step is in the wonderful world of Frank/Cucumber testing

Scenario: 
    Launching the app

Given I launch the app

步驟定義文件位於step_definitions文件夾中,並命名為launch_steps.rb。 代碼是:

def app_path
  ENV['APP_BUNDLE_PATH'] || (defined?(APP_BUNDLE_PATH) && APP_BUNDLE_PATH)
end

Given /^I launch the app$/ do
  launch_app app_path
end

但是,當我在終端中運行黃瓜時,沒有得到正確的輸出。 以下是終端的日志

features git:(frank) ✗ cucumber my_first.feature
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/universal-darwin13/rbconfig.rb:212: warning: Insecure world writable dir /usr/local in PATH, mode 040777
Feature: 
  As an iOS developer
  I want to have a sample feature file
  So I can see what my next step is in the wonderful world of Frank/Cucumber testing

  Scenario:                # my_first.feature:6
      Launching the app
    Given I launch the app # my_first.feature:9

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

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

Given(/^I launch the app$/) do
  pending # express the regexp above with the code you wish you had
end

If you want snippets in a different programming language,
just make sure a file with the appropriate file extension
exists where cucumber looks for step definitions.

我正在嘗試學習黃瓜,並且作為第一個功能,我正在嘗試啟動該應用程序。 因此,我期望該應用程序將使用此功能啟動。

PS:我尚未從XCode執行應用程序。

我找到了答案。 我們需要從目錄的更高級別運行它。

您應該嘗試看看黃瓜幫助的第一個選擇

 bundle exec cucumber --help

-r, --require LIBRARY|DIR        Require files before executing the features. If this
                                 option is not specified, all *.rb files that are
                                 siblings or below the features will be loaded auto-
                                 matically. Automatic loading is disabled when this
                                 option is specified, and all loading becomes explicit.
                                 Files under directories named "support" are always
                                 loaded first.
                                 This option can be specified multiple times.

然后您可以運行:

bundle exec cucumber features/my_first.feature -r features/

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM