4

我尝试使用 calabash-ios 测试框架来实现 UI 测试。我遵循了在不同站点上传播的所有方法和教程(xamarin testcloud 指南,在 github 上的 calabash-ios 框架,...)

在我的项目文件夹中,我创建了功能目录calabash-ios gen

我的项目结构如下:(只是一些文件夹/文件)

- Certificates
- Resources
- Solutions
- Source
|- B2.Device.Core.iOS
|- B2.Device.Service.iOS
|- B2.Device.iOS
 |- AppDelegate.cs
 |- B2.Device.iOS.csproj
 |- Info.plist
 |- MyFooViewController.cs
 |- MyBarViewController.cs
 |- bin
  |- iPhone
  |- iPhoneSimulator
   |- Debug
    |- *.dll
    |- B2DeviceiOS.app
    |- B2DeviceiOS.exe
 |- features
  |- my_first.freature
  |- step_definitions
   |- *.rb
  |- support

cucumber在里面调用Source/B2.Device.iOS/会抛出异常:

Dannys-MacBook-Air:B2.Device.iOS dannyyy$ cucumber 
Feature: Running a test
  As an iOS developer
  I want to have a sample feature file
  So I can begin testing quickly

  Scenario: Example steps                            # features/my_first.feature:6
  Unable to find *.xcodeproj in /Users/dannyyy/Projects/BauPlusMobile/Trunk/Source/B2.Device/B2.Device.iOS (RuntimeError)
  /var/folders/6p/s4dwcb0x1yx9wjjk_51ds21r0000gn/T/Calabash-CA09BEA0-1735-4818-AB85-4874C6849183/Gems/gems/calabash-cucumber-0.9.162/lib/calabash-cucumber/launch/simulator_helper.rb:61:in `derived_data_dir_for_project'
  /var/folders/6p/s4dwcb0x1yx9wjjk_51ds21r0000gn/T/Calabash-CA09BEA0-1735-4818-AB85-4874C6849183/Gems/gems/calabash-cucumber-0.9.162/lib/calabash-cucumber/launch/simulator_helper.rb:153:in `app_bundle_or_raise'
  /var/folders/6p/s4dwcb0x1yx9wjjk_51ds21r0000gn/T/Calabash-CA09BEA0-1735-4818-AB85-4874C6849183/Gems/gems/calabash-cucumber-0.9.162/lib/calabash-cucumber/launcher.rb:148:in `relaunch'
  /Users/dannyyy/Projects/BauPlusMobile/Trunk/Source/B2.Device/B2.Device.iOS/features/support/01_launch.rb:29:in `Before'
    Given I am on the Welcome Screen                 # features/step_definitions/my_first_steps.rb:1
    Then I swipe left                                # calabash-cucumber-0.9.162/features/step_definitions/calabash_steps.rb:237
    And I wait until I don't see "Please swipe left" # calabash-cucumber-0.9.162/features/step_definitions/calabash_steps.rb:168
    And take picture                                 # calabash-cucumber-0.9.162/features/step_definitions/calabash_steps.rb:232

Failing Scenarios:
cucumber features/my_first.feature:6 # Scenario: Example steps

1 scenario (1 failed)
4 steps (4 skipped)
0m1.043s

如果我使用 Xamarin.iOS 环境进行开发,怎么可能拥有 XCode 项目文件?我也尝试设置DEVICE_BUNDLE_PATH=~/Projects/BauPlusMobile/Trunk/Source/B2.Device/B2.Device.iOS/bin/iPhoneSimulator/Debug

但是当然会抛出同样的异常!

我看到的所有视频演示和截屏视频都使用 Xamarin.iOS 环境,但没有出现此错误。

进行测试的唯一方法是cucumber NO_LAUNCH=1在 Xamarin Studio 中调用并启动应用程序并附加调试器。

我希望有一个人可以帮助我。

4

1 回答 1

7

经过大量尝试和错误后,我得到了解决问题的方法。我想我会为使用 Xamarin.iOS 环境的用户解决一般问题。

  1. 更改到包含*.csproj
    在我的情况下的项目文件夹> cd ~/Projects/MyProject/Trunk/Source/B2.Device/B2.Device.iOS
  2. 生成features目录
    > calabash-ios gen
    • 如果你还没有安装 calabash-ios,让我们开始吧
      > sudo gem install calabash-cucumber
  3. 创建config目录并切换到它
    > mkdir config
    > cd config
  4. 创建一个名为cucumber.yml
  5. 将以下内容放入其中(配置文件名称以及其他环境变量可以更改以满足您的需要)

    # YAML Template
    ---
    ipad-sim: APP="~/Projects/MyProject/Trunk/Source/B2.Device/B2.Device.iOS/bin/iPhoneSimulator/Debug/B2DeviceiOS.app" BUNDLE_ID="tld.domain.project" SDK_VERSION=6.1
    
  6. 返回您的项目目录并开始您的测试
    > calabash-ios -p ipad-sim
于 2013-11-22T18:37:25.840 回答