Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cucumber/Calabash-iOS and Xamarin.iOS

I try to implement UI testing with the calabash-ios testing framework. I followed all the howtos, tutorials spread on the different sites (xamarin testcloud guide, on github for the calabash-ios framework, ...)

In my project folder I created the feature directory with calabash-ios gen

My project structure is like the following: (just some of the folder/file(s)

- 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

Calling cucumber inside Source/B2.Device.iOS/ throws an exception:

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

How it's possible to have a XCode project file if I'm developing with the Xamarin.iOS environment? I tried also to set the DEVICE_BUNDLE_PATH=~/Projects/BauPlusMobile/Trunk/Source/B2.Device/B2.Device.iOS/bin/iPhoneSimulator/Debug

But of course the same exception will be thrown!

All the video demos and screencasts I have seen were working with Xamarin.iOS environment but without this error.

The only way to get working the tests is calling cucumber NO_LAUNCH=1 and starting the app within Xamarin Studio with debugger attached.

I hope some one can help me.

like image 336
dannyyy Avatar asked Mar 21 '23 14:03

dannyyy


1 Answers

After a lot of try and error I got the solution for my problem. I guess I'll solve the problem in general for users which are working with the Xamarin.iOS environment.

  1. Change to your project folder which contains the *.csproj
    In my case > cd ~/Projects/MyProject/Trunk/Source/B2.Device/B2.Device.iOS
  2. Generate the features directory
    > calabash-ios gen
    • If you haven't calabash-ios installed yet lets start
      > sudo gem install calabash-cucumber
  3. Create config directory and change to it
    > mkdir config
    > cd config
  4. Create a file called cucumber.yml
  5. Put the following content into it (the profile name as well as the other environment variables could be changed to meet your need)

    # 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. Go back to your project directory and start your tests
    > calabash-ios -p ipad-sim
like image 97
dannyyy Avatar answered Mar 28 '23 23:03

dannyyy