Xamarin iOS and Android End-to-end testing
The Goods
Installation on Windows
- Ruby 1.9.2 -> install it (x86 version)
- DevKit -> extract it -> run "devkitvars.bat"
- ANSICON -> add to your path -> run:
ansicon.exe -i
gem install cucumber
gem install rspec
References
- Awesome, in-depth tutorial
- Calabash API - Reference for both iOS and Androud
- Xamarin Calabash Tutorials
- Xamaramin - Creating Calabash Tests
- Details and troubleshooting
Createing Android Tests
generate a skeleton:
calabash-android gen
Note the location of your Signed APK file that is generated by Xamarin
Create a .bat file that will run your tests
RunEndToEndTest.bat
calabash-android run ../MyMobileApp/MyMobileApp/bin/Debug/com.somename.mymobileapp-Signed.apk
Add a Login Feature
- In the folder structure /features/ create a new feature:
login.feature
Feature: Login feature
Scenario: As a valid user I can log into my app
When I press "Login"
Then I see "Specific Text on Next Activity Screen"
- In the folder structure /features/step_definitions/ create a new file:
login_steps.rb
require 'calabash-android/calabash_steps'
require 'calabash-android/operations'
extend Calabash::Android::Operations
Given(/^I try to login$/) do
tap("button marked:'Login'")
end
Then(/^I should see the error message "(.*?)"$/) do |my_message|
text_view = query("textView marked:'myTextView' {text CONTAINS '#{my_message}'}")
raise "The configuration message '#{my_message}' is not visible in the View." unless text_view.any?
end
Ruby Editor
- Free Editor: Pry
- or just use Sublime