运行 在 iOS 上进行 Calabash 测试时出现“无法自动检测 APP_BUNDLE_PATH”错误

“Unable to auto detect APP_BUNDLE_PATH” error while running the Calabash test on iOS

我是 Calabash iOS 自动化测试的新手。我已经在 Snow Leopard(版本 10.6 .8)

我 运行 命令 “calabash-ios setup” 并为我的测试创建了一个目标(测试校准目标)iOS 项目。使用此命令,CFNetwork.framework 和 calabash.framework 被添加到测试校准目标。

之后,我 运行 “calabash-ios gen” 在终端中创建了一个名为 features 的子目录,并手动将 features 子目录添加到 test-校准目标。

我在features文件夹下的“sample.feature”文件中写了一个测试脚本,然后在终端执行cucumber命令来测试脚本。

在 运行 命令之后它给我以下错误:

Scenario: Sample test                          # features/sample.feature:3

 Unable to auto detect APP_BUNDLE_PATH.
  Have you built your app for simulator?

Searched dir: /Users/octaneconference/Library/Developer/Xcode/DerivedData/Test-frkimcejhwemmaaapwknwfwvhnmb

Please build your app from Xcode

You should build the -cal target.

  Alternatively, specify APP_BUNDLE_PATH in features/support/01_launch.rb
  This should point to the location of your built app linked with calabash.
   (RuntimeError)

  ./features/support/01_launch.rb:29:in `Before'
    Given the app has launched                   # features/steps/sample_steps.rb:1
    And then the Sound Enable screen will appear # features/sample.feature:5
    When click on "NO" button                    # features/sample.feature:6
    Then Menu screen will appear in the screen   # features/sample.feature:7
    Then take a picture                          # features/sample.feature:8

Failing Scenarios:

cucumber features/sample.feature:3 # Scenario: Sample test

1 scenario (1 failed)
5 steps (1 skipped, 4 undefined)
0m0.965s

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

Given(/^then the Sound Enable screen will appear$/)
do

pending # Write code here that turns the phrase above into concrete actions
end

When(/^click on "([^"]*)" button$/) do |arg1|

  pending # Write code here that turns the phrase above into concrete actions
end

Then(/^Menu screen will appear in the screen$/) 

do
  pending # Write code here that turns the phrase above into concrete actions

end

Then(/^take a picture$/) do

pending # Write code here that turns the phrase above into concrete actions

end     

如果 suggestions/thoughts 解决此问题,我将不胜感激。

对于初学者,请确保您至少使用 OSX Yosemite 或更高版本,Xcode 6 或更高版本(最好 >= 7),并确保您拥有最新 calabash-cucumber gem(在撰写本文时,0.17.0)。您可以通过 运行ning

验证这一点
calabash-ios version

其次,您从哪里 运行 宁 cucumber 命令?如果您尝试从 xcode 项目在模拟器上对 运行 进行测试,则需要与 <app_name>.xcodeproj 位于同一目录中。正如错误消息所暗示的那样,您还需要确保在 运行ning 之前确实为模拟器构建了项目。

如果您尝试 运行 在模拟器应用程序包(扩展名为 .app 的文件夹)上进行测试,那么您可以 运行:

APP_BUNDLE_PATH=/path/to/appname.app DEVICE_TARGET="<UUID>" cucumber

(你可以通过 运行ning instruments -w devices 找到你的模拟器的uuid)

对于它的价值,我还建议您查看 calabash-sandbox 以获得简化的 ruby 设置。