黄瓜/ Calabash-iOS和Xamarin.iOS

dan*_*yyy 4 cucumber xamarin.ios ios xamarin calabash

我尝试使用calabash-ios测试框架实现UI测试.我按照所有的howtos,在不同网站上传播的教程(xamarin testcloud guide,在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
Run Code Online (Sandbox Code Playgroud)

调用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
Run Code Online (Sandbox Code Playgroud)

如果我正在使用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中调用和启动应用程序.

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

dan*_*yyy 7

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

  1. 切换到包含*.csproj
    In my case的项目文件夹> 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
    
    Run Code Online (Sandbox Code Playgroud)
  6. 返回项目目录并开始测试
    > calabash-ios -p ipad-sim