When I started looking for an automation framework for iOS, I originally started off with Calabash in mind. Looking at the documentation, everything looked great, but when it came down to it, no matter what I did, I could not get it to work in iOS 7. Since the apps I’ve been working on didn’t even get released until 8 months after iOS 7 was released, we didn’t even consider iOS 6 compatibility. That, along with the fact that we use an xcworkspace made all of my attempts to use Calabash end in frustration. The one time I finally got the thing to launch in the simulator, I couldn’t get Calabash to interact with the application at all, I just kept getting vague errors. The whole thing makes me angry just thinking about it.
So then I started looking elsewhere when I found out 2 things (references).
- Calabash is a derivative of Frank.
- Calabash’s 0.10 release line is intended to be a plugin for Frank.
Finding out this new information, I decided to look into Frank. Frank is not perfect by any means, it has a higher learning curve, and some things are unintuitive, but so far, there’s nothing I haven’t been able to figure out, and the tests remain abstract enough to allow for deviations in the UI.
Unfortunately, the most difficult thing for me was getting Frank to work with RSpec instead of Cucumber. I found a few links for people asking how to do this, but never any answers. (1, 2). Basically the biggest reason to use Cucumber instead of RSpec is that Frank doesn’t have a very good DSL. But let’s get serious, a terrible ruby api is still better than Cucumber.
After getting familiar with the Frank source code, turns out setting things up to use RSpec is pretty easy.
We’re going to use the same basic folder structure that we would for any other automation with RSpec.
All of your features go in the features folder and all of your helpers go in the helpers folder. Remember that with RSpec, all of your features should_be_named_like_this and end with ‘_spec.rb’.
Typically I create a bunch of ‘variable classes’ to keep the shelly selectors abstracted out of the spec files, and I create a bunch of ‘helper classes/modules’ to keep complex operations in. That way the spec files have less repeated code and are a little more intuitive. It keeps them from being scattered with string literals of selectors.
Inside your spec_helper is where all of the magic happens. If you’re curious of how I came to this, I basically just converted this file from Cucumber to RSpec. (I left out all of the FrankMac stuff because I’m only using it for iOS testing)
#This path may change depending on where your spec_helper is
APP_BUNDLE_PATH = File.expand_path( '../frankified_build/Frankified.app', __FILE__ )
RSpec.configure do |config|
#This gets rid of some warning. I'm not really sure what it does other than that
I18n.enforce_available_locales = false
config.before :all do
launch_app APP_BUNDLE_PATH, ENV['FRANK_SDK'], 'ipad'
Once you have your spec_helper set up, then you just need to start writing your features (and make sure you require your spec helper in all of your features).
For more information on using Frank’s ruby api, I did a followup post here.