Phew! Dogpatch Technology is now simultaneously developing for both iPhone and Android while using an RSpec styled testing framework. Here’s how we do it.
We found a blog post at Levid Media on how they setup Jasmine for use with Titanium, but it seemed a little out of date and lacking in some key details, so here’s how we set it up on our Snow Leopard dev machine.
Before you start, make sure you’ve installed Jasmine as a ruby gem. Levid has a quick tutorial on it. Also make sure you’ve installed the latest Appcelerator Developer Package, have downloaded the latest mobile SDK (1.5.1 as of this post), and have created a new Titanium mobile project for yourself. Now you’re ready to set up Jasmine as your framework.
First, in the root of your project directory, run:
Your root project directory should look something like:
CHANGELOG.txt LICENSE.txt Rakefile build public tiapp.xml LICENSE README Resources manifest spec
# helpers # # Return an array of filepaths relative to spec_dir to include before jasmine specs. # Default: ["helpers/**/*.js"] # # EXAMPLE: # # helpers: # - helpers/**/*.js # helpers:
Notice I left the helper files blank here.
# spec_files # # Return an array of filepaths relative to spec_dir to include. # Default: ["**/*[sS]pec.js"] # # EXAMPLE: # # spec_files: # - **/*[sS]pec.js # spec_files: - *[sS]pec.js
# src_dir # # Source directory path. Your src_files must be returned relative to this path. Will use root if left blank. # Default: project root # # EXAMPLE: # # src_dir: public # src_dir:
We didn’t set src_dir to Resources due to the helper file hack, so left this blank.
And point your browser to http://localhost:8888/ and any spec tests you have will be run. It’s a heck of a lot easier, especially for Android development to write most of your code using your specs rather than recompiling and launching it from the emulator.
Also it’s relatively easy to set up a hudson continuous integration job that just checks your repository and runs:
So yes, you CAN do mobile cross platform development with BDD and continuous integration. Any excuses for not testing your code pointing to how mobile development lacks good cross-platform development tools are just plain wrong. And I’m sure there are better ways to do it. Feel free to drop us a line at dev (~at~) dogpatchtech.com with any questions or comments.