1

我写了一个特性和一个步骤定义。但是,黄瓜没有识别步骤定义。

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

但是,当我在终端中运行 cucumber 时,我没有得到正确的输出。以下是来自终端的日志

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 执行应用程序。

4

2 回答 2

0

我找到了答案。我们需要从目录的上一级运行它。

于 2013-12-22T08:42:17.043 回答
0

您应该尝试查看黄瓜帮助的第一个选项

 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/
于 2014-09-02T15:34:30.240 回答